Bird
0
0

Why might you choose worker_threads over cluster for parallelism in a Node.js application?

hard📝 Conceptual Q10 of 15
Node.js - Worker Threads
Why might you choose worker_threads over cluster for parallelism in a Node.js application?
ABecause worker_threads share memory and have lower overhead than cluster processes
BBecause cluster supports only Windows OS
CBecause worker_threads automatically restart on failure
DBecause cluster cannot handle HTTP requests
Step-by-Step Solution
Solution:
  1. Step 1: Compare memory sharing

    Worker threads share memory via SharedArrayBuffer, reducing overhead compared to separate processes in cluster.
  2. Step 2: Understand cluster limitations

    Cluster creates separate processes with more overhead and no shared memory.
  3. Final Answer:

    Because worker_threads share memory and have lower overhead than cluster processes -> Option A
  4. Quick Check:

    worker_threads share memory, cluster uses processes [OK]
Quick Trick: Worker threads share memory; cluster uses separate processes [OK]
Common Mistakes:
  • Thinking cluster is Windows-only
  • Assuming worker_threads auto-restart
  • Believing cluster can't handle HTTP

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes