offloading
Moving slow or heavy work off the main thread to another thread or process, so the event loop stays free to handle other requests.
In more detail
libuv offloads file system calls and some crypto to its thread pool automatically. Your own CPU-bound code can be offloaded to worker threads or child processes.
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.
- worker threads — The Node.js module for running JavaScript in parallel threads inside one process, each with its own V8 isolate and event loop.
- 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.
Taught in
- libuv Architecture: Event Demultiplexer & Thread Pool — Node.js Internals & Backend Services
- Asynchronous File I/O: node:fs/promises & Handles — Node.js Internals & Backend Services
- Directory Traversal: Recursive Readdir & fs.watch — Node.js Internals & Backend Services