Bird
0
0

Why does Node.js recommend forking workers equal to the number of CPU cores instead of more or fewer?

hard📝 Conceptual Q10 of 15
Node.js - Cluster Module
Why does Node.js recommend forking workers equal to the number of CPU cores instead of more or fewer?
ATo minimize memory usage by limiting workers
BTo ensure workers never share any resources
CBecause Node.js cannot handle more than one worker per core
DTo maximize CPU usage without causing excessive context switching
Step-by-Step Solution
Solution:
  1. Step 1: Understand CPU core utilization

    Forking one worker per core uses all CPU cores efficiently without overloading the system.
  2. Step 2: Avoid excessive context switching

    More workers than cores cause frequent switching, reducing performance; fewer workers underuse CPU.
  3. Final Answer:

    To maximize CPU usage without causing excessive context switching -> Option D
  4. Quick Check:

    Optimal worker count reason = B [OK]
Quick Trick: Match workers to CPU cores to avoid slowdowns [OK]
Common Mistakes:
  • Thinking Node.js limits workers per core
  • Believing fewer workers always save memory
  • Assuming workers never share resources

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes