Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Node Child Process Spawn Run on Multi Core CPU?

When I call .spawn to make a new child process in Node.js, does this take advantage of multi-core CPUs?

Reference: https://nodejs.org/api/child_process.html

like image 805
Kirk Ouimet Avatar asked Oct 28 '15 02:10

Kirk Ouimet


People also ask

Does node run on multiple cores?

NodeJS uses Javascript to develop server side applications and shares the same behavior. It runs on one CPU core regardless of how many CPU cores you have in your machine or a virtual machine in the cloud.

How does NodeJS handle child process?

Usually, Node. js allows single-threaded, non-blocking performance but running a single thread in a CPU cannot handle increasing workload hence the child_process module can be used to spawn child processes. The child processes communicate with each other using a built-in messaging system.

How many cores does NodeJS use?

Not many realize that NodeJS runs in a single thread by default. Besides, it utilizes only one CPU core for this thread. So, for example, if you're using a 4 core machine, Node will only be using a single core.

Does node run on single core?

Generally, if the child process or cluster modules are not involved, then there is no benefit from having multiple cores on your system, because Node. js will only use one core. One example of a single-threaded application would be a simple HTTP server like the following: http.


1 Answers

Yes, a new process will be created and managed by your OS. That new process can be executed in parallel to the main process as long as your computer has at least 2 virtual CPU cores.

like image 50
Yuri Zarubin Avatar answered Nov 29 '22 22:11

Yuri Zarubin