CPU-bound work
Work limited by how fast the processor can calculate, such as hashing or parsing, rather than by waiting for disk or network.
In more detail
CPU-bound work on the main thread blocks the event loop, so every other request waits. Move it to worker threads, a worker pool or a child process.
Related terms
- worker threads — The Node.js module for running JavaScript in parallel threads inside one process, each with its own V8 isolate and event loop.
- 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.
- blocking I/O — An operation that makes the program stop and wait until it finishes, so nothing else on that thread can run meanwhile.
Taught in
- libuv Architecture: Event Demultiplexer & Thread Pool — Node.js Internals & Backend Services
- Timers Phase: setTimeout, Min-Heap Scheduling & Drift — Node.js Internals & Backend Services
- Worker Threads: worker_threads & SharedArrayBuffer — Node.js Internals & Backend Services
- Thread Pooling: Piscina & CPU-Bound Workload Pools — Node.js Internals & Backend Services