node.jsnode-cluster

What is the algorithm behind NodeJS cluster?


The head is fairly self explanatory :)

Node supports process clustering (documentation). But in the documentation I failed to see what algorithm does it use to distribute work to workers.

Is it round-robin? PM2 is using round robin afaik.


Solution

  • Based on the How It Works part of the documentation, it is mentionned that Cluster uses round-robin by default on most platforms (except on Windows).

    You might also want to check out cluster.schedulingPolicy for a list of available policies.