Bird
0
0

What will happen if you call cluster.fork() multiple times in the master process?

medium📝 Predict Output Q5 of 15
Node.js - Cluster Module
What will happen if you call cluster.fork() multiple times in the master process?
AOnly one worker process will be created regardless
BThe master process will crash
CMultiple worker processes will be created
DThe workers will share the same process ID
Step-by-Step Solution
Solution:
  1. Step 1: Understand fork behavior

    Each call to cluster.fork() creates a new worker process.
  2. Step 2: Clarify process IDs and stability

    Workers have unique process IDs; the master remains stable and does not crash.
  3. Final Answer:

    Multiple worker processes will be created -> Option C
  4. Quick Check:

    Multiple forks create multiple workers = B [OK]
Quick Trick: Each fork call spawns a new worker process [OK]
Common Mistakes:
  • Thinking only one worker is created
  • Assuming master crashes on multiple forks
  • Believing workers share process IDs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes