concurrency-scalingAnswer last reviewed July 2026

Node's cluster module, when a connection comes in, how does it actually decide which worker gets it?

A strong answer follows a connection from accept to worker under both scheduling modes, and can say why long-lived connections defeat round-robin.

What an AI-prepared candidate might say

Cluster forks a bunch of Node processes that cooperate so one port serves all of them. With the default scheduling policy, which is round-robin, the primary process accepts the incoming connections and hands them out to workers in turn, so the load stays roughly even. On Windows the default is different, the OS decides which process gets each connection there. Every worker runs your full server code. For long-lived stateful protocols like WebSockets, or Socket.IO holding session state, you need sticky sessions, meaning the same client always lands on the same worker, and round-robin doesn't guarantee that, so you add affinity at a proxy or hash by client address or something like that. There's also SO_REUSEPORT as an alternative to the whole arrangement, where each worker opens its own listening socket and the kernel spreads the connections between them.

Senior
Locked

Which process really owns the listening socket under SCHED_RR versus SCHED_NONE, how a live TCP connection crosses a process boundary, and why sticky sessions exist.

Unlock the depth
Staff
Locked

Diagnosing a hot worker when connection counts look even, the keep-alive fairness problem, and an honest look at letting the kernel distribute via SO_REUSEPORT.

Unlock the depth
Follow-up chain
Node's cluster module, when a connection comes in, how does it actually decide which worker gets it? | NodeBook