The master process is responsible for managing the lifecycle of worker processes — spawning, monitoring, and restarting them. Worker processes contain the actual application logic and handle incoming client requests independently.
In a clustered Node.js application, the roles of the master and worker processes are clearly separated. The master process acts as an orchestrator — it never handles HTTP requests directly. Workers are the actual application servers that process requests and respond to clients.
Spawn worker processes using cluster.fork()
Monitor worker health and listen for exit events
Restart dead workers automatically
Distribute incoming connections to available workers
Send configuration or messages to workers via IPC
Run the actual HTTP server or application logic
Handle incoming requests assigned by the master
Send and receive messages to/from the master via IPC
Operate independently with their own memory space