Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expressjs multiple threads

It is possible to have multiple threads on nodejs? I am using expressjs and multer for image upload. When an image have big size and webpage needs another request to be accomplished, it waits until image get uploaded. It's possible to make image upload use other thread?

like image 867
Honchar Denys Avatar asked Sep 14 '15 10:09

Honchar Denys


1 Answers

Node.js focuses on asynchronous processing. It is capable of accepting an image upload and servicing other requests at the same time. If it is not doing that it is because your code is doing some kind of synchronous processing. There is a cluster module for running the same node.js code across multiple processes (rather than threads); but it is not what you want. You may find it interesting to understand the difference between concurrency and parallelism. That article is focussed on the Go language so you don't get hung up on node.js specifics. You don't need another thread - you need to better understand the way node.js works. Perhaps you could post the relevant parts of your code in another question for more specific feedback.

like image 86
Alex Taylor Avatar answered Oct 16 '22 06:10

Alex Taylor