0
0
Node.jsframework~5 mins

How cluster module works in Node.js - Quick Revision & Summary

Choose your learning style9 modes available
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?
ACreating user interfaces
BImproving database queries
CManaging file uploads
DUtilizing multiple CPU cores to handle requests
Who creates the worker processes in a Node.js cluster?
AThe master process
BEach worker creates itself
CThe operating system automatically
DThe client browser
How do workers share the same port in a cluster?
AWorkers do not share ports
BThe operating system distributes connections to workers
CEach worker listens on a different port
DWorkers use different IP addresses
What happens when a worker crashes in a cluster?
AThe master restarts a new worker
BThe whole server stops
CNothing happens automatically
DThe client reconnects automatically
Which communication method is used between master and workers?
AHTTP requests
BWebSockets
CIPC (Inter-Process Communication)
DFile system polling
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.