Node.js cluster uses IPC (Inter-Process Communication) channels to allow message passing between the master and worker processes using worker.send() from the master and process.send() from the worker, with corresponding 'message' event listeners on both sides.
Each worker automatically has an IPC channel established with the master at the time of forking. Messages are serialized as JSON internally, so you can pass any JSON-serializable data. This is the primary way to coordinate shared state or tasks across workers since they cannot share memory directly.
Sending configuration updates to all workers dynamically
Aggregating metrics or counters from workers into the master
Notifying the master when a worker is ready or busy
Broadcasting messages to all workers from the master
Coordinating graceful shutdown sequences
You need to offload a CPU‑heavy image resize to a worker using Node's cluster module. How would you send the job description from the master to a worker and get the result back?
If a worker calls process.send({type:'ready'}), what does the master need to do to receive that message?
What happens if you call process.send in a script that isn’t running under a cluster?
During a rollout you notice some workers never receive the 'shutdown' command you broadcast from the master. Walk me through how you would debug the message flow.
You need to implement a request‑reply pattern where the master forwards HTTP requests to workers and aggregates responses. What trade‑offs do you consider when choosing between process.send and a shared memory approach?
Explain why a worker might crash when handling a large JSON payload sent via process.send, and how you’d mitigate it.
Your service runs on 64 cores and uses the cluster module to spawn workers. How would you design the messaging layer to avoid back‑pressure and keep throughput high?
Discuss the implications of using process.send for transmitting binary data versus using a dedicated message queue like Redis under high load.
If you need to hot‑swap code in workers without dropping in‑flight messages, how would you coordinate the handoff using cluster IPC?
Your organization is moving from a monolithic Node app using cluster to a microservices architecture. How would you evaluate whether to keep intra‑process messaging via process.send or replace it with an external broker?
Across multiple teams, some services rely on cluster IPC while others use gRPC. What guidelines would you establish to maintain consistency and avoid coupling?
Design a migration plan to phase out Node's built‑in cluster messaging in favor of a platform‑wide event bus, addressing backward compatibility and operational monitoring.