On Thursday, March 3, 2016 at 7:11:14 AM UTC+1, Ajay Kumar Jaiswal wrote:
>
>
>
>
>>> The recored set contains millions of record so if i convert it using npm 
>>> json2xls it makes busy the browser and server to converting json into  xlsx 
>>> .so this approach i don't want to use.
>>>
>>
> Even i convert it using "\t" and "\n". it blocks the other process . how 
> to resolve it. i am dealing with large data set. 
>


You could stream your response to the client. It will involve several 
stages in your stream pipeline.
Client opens the request, so you then:
- get the connection
- get the result stream, preferably something in object mode that gives you 
row by row
- pipe it to a stream that will convert result set row into a CSV table row 
(or excel, not sure if you can make that work as a stream though).
- pipe that stream to response.

Then your stream is nice and non-blocking. It's still CPU hungry and lasts 
long, but it doesn't block the server completely, so you can serve multiple 
clients in the same time.

Alternatively, spawn another process that will run your conversion (like 
json2xls). So your server takes a request, and if there is available 
capacity, spawns a process to handle this conversion, returning you a tmp 
file location or something of the sort. Then your server will still work 
for the other, regular requests because this processing is essentially off 
your main process.

Or do something like a two-step process - take the request and put it on 
your job queue - then tell the client "ok, I'll inform you when it's 
ready". Then this job queue is on a separate node or similar process, and 
it informs the client when the xls is ready ;)

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/380f623a-3675-455b-ae71-cc3de4c8f5a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to