How do I change the thread pool size in Node.js?
Set UV_THREADPOOL_SIZE in the environment before starting Node.js. The default is 4. Increasing it can help if your app does many thread-pool operations, but monitor CPU usage since more threads mean more CPU contention.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in What Is the Thread Pool in libuv and How Does It Work in Node.js?
A pool of 4 threads (by default) in libuv that handles operations which the OS cannot do asynchronously, like certain file system operations, DNS lookups, and crypto operations. These run off the main thread so they do not block the event loop.
Because the OS cannot handle all operations asynchronously. File system operations, some DNS lookups, and some crypto work are blocking. The thread pool runs these on separate threads so the main thread's event loop stays free.
File system operations (fs module), DNS lookups (dns.lookup), some crypto operations (crypto.pbkdf2), and some zlib operations. Network I/O does not use the thread pool; it uses the OS's async capabilities directly.
Still have questions?
Browse all our FAQs or reach out to our support team
