Recall & Review
beginner
What is the purpose of the Node.js cluster module?
The cluster module allows Node.js to create child processes (workers) that share the same server port, enabling better use of multi-core CPUs and improving performance by handling multiple requests in parallel.
Click to reveal answer
intermediate
How does the cluster module share server ports among worker processes?
Worker processes listen on the same port, and the operating system distributes incoming connections to workers using round-robin load balancing (on some platforms), allowing load balancing across CPU cores without conflicts.
Click to reveal answer
intermediate
What is the role of the master process in the cluster module?
The master process manages worker processes: it creates them, listens for their exit events, and can restart workers if they crash, ensuring the application stays available.
Click to reveal answer
advanced
How do worker processes communicate with the master process in the cluster module?
Workers and the master communicate using an IPC (Inter-Process Communication) channel, allowing them to send messages and coordinate tasks like graceful shutdowns or sharing state.
Click to reveal answer
intermediate
What happens if a worker process crashes in a Node.js cluster setup?
The master process detects the crash via an 'exit' event and can automatically spawn a new worker to replace the crashed one, keeping the service running smoothly.
Click to reveal answer
What does the Node.js cluster module primarily help with?
✗ Incorrect
The cluster module helps Node.js apps use multiple CPU cores by creating worker processes.
Who creates the worker processes in a Node.js cluster?
✗ Incorrect
The master process is responsible for creating and managing worker processes.
How do workers share the same port in a cluster?
✗ Incorrect
Workers listen on the shared port, and the operating system distributes incoming connections to workers.
What happens when a worker crashes in a cluster?
✗ Incorrect
The master detects the crash and can restart a new worker to maintain service.
Which communication method is used between master and workers?
✗ Incorrect
Master and workers communicate via IPC channels built into Node.js cluster.
Explain how the Node.js cluster module improves application performance on multi-core systems.
Think about how multiple workers handle requests at the same time.
You got /4 concepts.
Describe the lifecycle of a worker process in the Node.js cluster module.
Consider what happens from start to crash and restart.
You got /5 concepts.