Which Node.js operations use the thread pool?
File system operations (fs module), DNS lookups (dns.lookup), and some crypto operations (crypto.pbkdf2). Network I/O does not use the thread pool; it uses the OS's async capabilities directly.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in How the libuv Thread Pool Works in Node.js
A pool of 4 threads (by default) in libuv that handles operations which cannot be done asynchronously by the OS, like certain file system operations, DNS lookups, and crypto work. 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 certain crypto work are blocking. The thread pool runs these on separate threads so the main thread's event loop stays free.
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.
Still have questions?
Browse all our FAQs or reach out to our support team
