Does Node Child Process Spawn Run on Multi Core CPU?
Asked Answered
C

1

8

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

Calesta answered 28/10, 2015 at 2:16 Comment(0)
A
8

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.

Amling answered 28/10, 2015 at 2:18 Comment(4)
what happens if you have 1 core and you spawn child processSingletree
The same thing that happens when you have multiple cores. The operating system schedules the execution of the processes amongst N cores, which in your case, would mean that all processes are being executed by 1 core.Amling
so you still get some benefit? if you have one core, and you create clusters, then processor will make them run in parallel ( even one task is long running? ) . I read somewhere intel processors do virtual core which let even single core act like multi core.Singletree
If the processes can be executed in parallel by the processor, then yes, you will get the benefit.Amling

© 2022 - 2024 — McMap. All rights reserved.