cluster module
The Node.js module that starts several copies of a server as worker processes sharing one port, so a machine's CPU cores can all serve requests.
In more detail
The primary process forks workers and, on Linux and macOS, hands incoming connections to them in turn. In containers it is often simpler to run one process per container and let the orchestrator scale.
Related terms
- primary process — The first process in a Node.js cluster, which starts and replaces worker processes and distributes connections to them.
- worker process — One of the processes forked by a cluster's primary to handle requests, each with its own memory and event loop.
- round robin — A way of spreading work by taking turns in a fixed order, giving the next item to the next recipient in the list.
- CPU core — One independent processing unit inside a CPU; a CPU with eight cores can run eight threads at literally the same time.
Taught in
- Cluster Architecture: node:cluster & Zero-Downtime — Node.js Internals & Backend Services