UV_THREADPOOL_SIZE
An environment variable that sets how many threads libuv's thread pool has; the default is 4 and the maximum is 1024.
In more detail
It must be set before the pool is first used, so it is normally given on the command line, as in UV_THREADPOOL_SIZE=8 node app.js. More threads help when many file, DNS or crypto jobs run at once, but each uses memory, and more threads than CPU cores rarely speeds up CPU-heavy work.
Related terms
- thread pool — A fixed or bounded set of reusable worker threads that take tasks from a queue, instead of creating a new thread for each task.
- environment variable — A named setting such as PORT=8000 that a program reads from its surroundings when it starts.
- libuv — The C library inside Node.js that runs the event loop, performs asynchronous I/O and manages the thread pool.
Taught in
- libuv Architecture: Event Demultiplexer & Thread Pool — Node.js Internals & Backend Services