Node.js · Senior · Question 16 of 75
Why should a server use a pool of worker threads instead of creating a new worker per request?
- ✓Correct answer: Starting a worker is expensive (new V8 isolate and event loop), so a fixed pool reuses workers and limits parallelism
- 2Node.js allows only one worker per process
- 3Workers created per request can't use
postMessage
Explanation
Libraries like Piscina manage a pool and a task queue. Size the pool close to the number of available cores.