Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js asynchronous call handling and multi-core scaling

It is known that node.js internally handles asynchronous calls and the programmer never needs to care about what is going on in the backstage. As far as I know, even if everyone says that node.js is only single thread, internally v8/libuv libraries are spawning threads to handle the execution of the async fragments of the program.

My question is if those threads are spawned, are they scaling the multicore architectures? I mean If I have a cpu with 4 cores and my main node thread is running on one of those CPU's, will those internally spawned threads scale to the other three CPU's and not remain on the same CPU. Theoretically they should scale but since everyone says node.js out-of-box is not using multiple cores, I thought this is worth asking.

like image 482
ralzaul Avatar asked Nov 10 '22 17:11

ralzaul


1 Answers

Node.js deals with one-thread-per-process. To make it scale out to multiple cores, you need to run multiple Node.js servers, one per core and split request traffic between them.

like image 170
Pragya Avatar answered Nov 15 '22 07:11

Pragya