Just starting out? Need help? Post your questions and find answers here.
menschmarkus
 
Posts: 25
Joined: Thu Apr 10, 2014 3:35 pm

Generating JSON File performance problem

by menschmarkus Fri Jul 24, 2020 1:22 pm

Hi,

in the moment I am facing a timing problem generating a JSON File and offer it for downloading it ( ExportFile() ).
So what happens:
User has possibility to select a CSV File with e.g.1000 lines. Each line is checked and the app send a request via php to my server for database research. Reply comes back with a JSON String in an acceptable time (OK thats a server thing...). I select the JSON String in a variable and add each result which comes from my server. At last I create a file and write the string variable to it and export it. Now, it takes up to 2 minutes until the file is written and ready to be downloaded (System save file Window appears). To be honest, the file size was 60 MB and may be larger if I increase the number of lines in CSV file.
So 2 things happens I am not really happy about.
1. Preparation of file takes very long
2. Browser message appears an app takes too long for reaction: Stop or wait app.
Does someone have an idea for better handling of huge data?

Useful discussion start now ;)
as soon you do it right, it works !
User avatar
Peter
 
Posts: 755
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080

Re: Generating JSON File performance problem

by Peter Fri Jul 24, 2020 2:14 pm

menschmarkus wrote:User has possibility to select a CSV File with e.g.1000 lines. Each line is checked and the app send a request via php to my server for database research.

Why not upload the whole file in one go and let the server do the work (including building the complete JSON)?
menschmarkus
 
Posts: 25
Joined: Thu Apr 10, 2014 3:35 pm

Re: Generating JSON File performance problem

by menschmarkus Mon Jul 27, 2020 1:54 pm

Why not upload the whole file in one go and let the server do the work (including building the complete JSON)?

Hm,
I will try it...
as soon you do it right, it works !
menschmarkus
 
Posts: 25
Joined: Thu Apr 10, 2014 3:35 pm

Re: Generating JSON File performance problem

by menschmarkus Thu Jul 30, 2020 2:21 pm

@Peter
facing a problem with uploading CSV file.
I tried falsams dropzone but this accept image files only. I checked the js file and found at line 342:
Code: Select all
acceptedFiles: null,

I changed it to
Code: Select all
acceptedFiles: text/csv,
(I also tried text/plain, text/comma-separated-values without success)
This did not work. The drop zone stays unaccesable so I could not select a file.

How can I release CSV Files for uploading, so where is the flag in js file?
(Sorry for this question but JS is not my world :oops: )
as soon you do it right, it works !
User avatar
Peter
 
Posts: 755
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080

Re: Generating JSON File performance problem

by Peter Thu Jul 30, 2020 2:33 pm

menschmarkus wrote:I tried falsams dropzone but this accept image files only.

I'm not so familiar with falsam's component. You can alternatively use my upload code: https://forums.spiderbasic.com/viewtopic.php?p=7249#p7249

Greetings ... Peter
menschmarkus
 
Posts: 25
Joined: Thu Apr 10, 2014 3:35 pm

Re: Generating JSON File performance problem

by menschmarkus Thu Jul 30, 2020 2:58 pm

Thanks Peter, I will try your code.
I will come back and report....
as soon you do it right, it works !
menschmarkus
 
Posts: 25
Joined: Thu Apr 10, 2014 3:35 pm

Re: Generating JSON File performance problem

by menschmarkus Fri Jul 31, 2020 1:07 pm

@ Peter: As promised, my report:

first of all thank you Peter, upload works fine.

Any Idea how to indicate the user about the progress status of Servers work?
as soon you do it right, it works !
User avatar
Peter
 
Posts: 755
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080

Re: Generating JSON File performance problem

by Peter Sat Aug 01, 2020 1:22 pm

menschmarkus wrote:Any Idea how to indicate the user about the progress status of Servers work?

Hard to say, because I don't know your project.

How big is the CSV you upload to the server? You could also send it to the server via HTTPRequest() The server will then send a kind of identification number back to the client. With this identification number the client could then ask the server cyclically how far the processing of the data has already progressed.

Greetings ... Peter
menschmarkus
 
Posts: 25
Joined: Thu Apr 10, 2014 3:35 pm

Re: Generating JSON File performance problem

by menschmarkus Sun Aug 02, 2020 5:44 pm

Peter wrote:I don't know you project
I just want to run Database request from a CSV File and send back a result (e.g. JSON string) of all requests in one reply.
Peter wrote:How big is the CSV you upload to the server?
As I mentioned in my first post could be 1000 or up to 10000 lines

Peter wrote: You could also send it to the server via HTTPRequest(). The server will then send a kind of identification number back to the client. With this identification number the client could then ask the server cyclically how far the processing of the data has already progressed.
OK inPB no problem but in SB? I do not have enough experience in SB to see the progress status actively.
In your sample for uploading files you finally upload it with a process called in HTTPRequest(). How long is this event alive, want to say how often can I fire a reply from my server to ctch the information? Debug mode shows after first return a status 200. I am a little confused about at what time a bind event stops listening.

rgds menschmarkus
as soon you do it right, it works !
menschmarkus
 
Posts: 25
Joined: Thu Apr 10, 2014 3:35 pm

Re: Generating JSON File performance problem

by menschmarkus Wed Aug 05, 2020 3:16 pm

@Peter
OK, It took a moment but I found a suitable solution for me.
Unfortunately the result is too big. There is no value returned by the PHP script if the result exceed a size (I do not know exactly where it stops offering Data but it may be limited by PHP ini setting).
I will write the result to a file on my server which is no problem but how can I prepare it for downloading it from my server to the client and offer the download?

Do you have a similar simple JS script for SB like the one for uploading files?

rgds
as soon you do it right, it works !
Return to Coding Questions

Who is online

Users browsing this forum: No registered users and 9 guests