Cluster with round-robin distribution of incoming connections

22 views
Skip to first unread message

Edmund Grimley Evans

unread,
Jun 27, 2017, 2:55:26 PM6/27/17
to nodejs
The "Cluster" documentation (https://nodejs.org/api/cluster.html#cluster_how_it_works) claims that "round-robin" is the default, except on Windows, and this information, together with similar example code, is repeated in dozens of blogs round the web. However, when I run the examples on Linux and look at the output from sudo strace -p "`pidof nodejs`" I find that it is not doing "round-robin" at all: the master process remains asleep, while the workers listen on the same socket and the kernel distributes incoming connections amongst them in a typically rather unbalanced fashion.

In order to get the "default", "round-robin" behaviour perhaps I have to create a socket before invoking cluster.fork. But how would I do that? Does anyone have an example that actually does what the documentation says is the default?
Reply all
Reply to author
Forward
0 new messages