What is the libuv thread pool?
A pool of 4 threads (default) in libuv that handles operations the OS cannot do asynchronously: certain fs operations, dns.lookup, and some crypto. These run off the main thread, and callbacks run on the main thread via the event loop.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Thread Pool and Worker Threads Interview Questions for Node.js
File system operations (fs module), DNS lookups (dns.lookup), some crypto operations (crypto.pbkdf2, crypto.scrypt), and some zlib operations. Network I/O does not; it uses the OS's async capabilities directly.
The thread pool is internal to libuv and handles specific I/O operations automatically. Worker threads are a Node.js API where your JavaScript code runs on separate threads for CPU-heavy computation. The thread pool is for I/O; worker threads are for computation.
Set UV_THREADPOOL_SIZE in the environment before starting Node.js. The default is 4. Increase it for apps with many fs, DNS, or crypto operations, but monitor CPU usage since more threads mean more contention on limited cores.
Still have questions?
Browse all our FAQs or reach out to our support team
