Node.js FAQ: Top Questions
45. What is the Node.js thread pool?
The thread pool in Node.js, managed by libuv, offloads blocking operations (e.g., file I/O, DNS) to a pool of worker threads, defaulting to 4 threads.
-
Operations:
fs
(e.g.,readFile
),crypto
, DNS lookups. -
Tuning:
Set
UV_THREADPOOL_SIZE
environment variable. - Limitations: Finite threads can bottleneck under heavy load.
- Use Case: Balancing I/O-bound tasks.