The context switching costs don't change just because you're using node. 
 The suggestion to spawn workers equal to the number of cores (really, it's 
#cores -1, so the spawning process can still run) comes from the assumption 
that there are no other processes demanding CPU time.

In some more reliable systems, care is taken to ensure there is enough cpu 
time available to non-workers which provide essential system services. 
 That way if any workers get out of hand, the system will still function at 
a minimum level.  The choice to implement something more complicated such 
as this is going to be based on the requirements of the system.  Since most 
systems won't have this kind of requirement, spawning a worker per core (- 
1) is a decent default policy.

Ultimately context switching costs in a scenario where you are doing 1 to 1 
node processes to core are pretty minimal as long as there are no other 
services running on the system which demand immediate cpu time or any long 
running computational load.  OS schedulers try to be smart about these 
issues, but not having enough RAM in a system where swapping is happening 
will make even trivial context switches (ie, allowing ssh to spawn a new 
user shell) bog down some running processes.

Hopefully this is what you were looking for?

On Monday, May 18, 2015 at 9:04:26 PM UTC-7, Alisson Cavalcante Agiani 
wrote:
>
> I see many articles saying to spawn workes equal to CPU cores, but what 
> about context switching cost?
>

-- 
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/2e5888e0-1be6-4362-b735-7f04a78226b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to