Node.js & Libuv•Part 2: Runtime Internals, Libuv & The Event Loop (6 - 20)
Scaling the thread pool with `UV_THREADPOOL_SIZE`.
In Simple Words: You can increase the thread pool size up to 128 by setting the environment variable before Node starts:
bash
UV_THREADPOOL_SIZE=16 node server.js
Must be set before any asynchronous operations execute. If saturated by heavy cryptographic hashing, file I/O operations will stall in the queue.
javascript
// Verifying thread pool setting in script:
process.env.UV_THREADPOOL_SIZE = '16'; // Must be set before any async call!