Bird
0
0

How can you share a server port between multiple worker processes in a Node.js cluster?

hard📝 Application Q9 of 15
Node.js - Cluster Module
How can you share a server port between multiple worker processes in a Node.js cluster?
ABy having the master process listen on the port and distributing connections
BBy having each worker listen on the same port independently
CBy using a shared memory variable to coordinate port usage
DBy assigning different ports to each worker
Step-by-Step Solution
Solution:
  1. Step 1: Understand port sharing in cluster

    The master process listens on the port and distributes incoming connections to workers.
  2. Step 2: Clarify why other options fail

    Workers cannot listen on the same port independently; shared memory does not control ports; different ports defeat clustering purpose.
  3. Final Answer:

    By having the master process listen on the port and distributing connections -> Option A
  4. Quick Check:

    Master listens and distributes port = D [OK]
Quick Trick: Master listens on port, workers handle connections [OK]
Common Mistakes:
  • Workers listening on same port independently
  • Using shared memory for port control
  • Assigning different ports to workers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes