For operations that cannot be done asynchronously, like certain file system operations. These go to libuv's thread pool (default 4 threads), so they run off the main thread without blocking the event loop.
What is the thread pool in Node.js for?
More FAQs in How Node.js Handles Concurrency on a Single Thread
Through the event loop and non-blocking I/O. When an async operation starts, the thread moves on. When it completes, its callback is queued, and the event loop processes callbacks one at a time. This lets one thread serve thousands of concurrent connections.
No. Node.js handles many concurrent connections. The JavaScript code runs on one thread, but I/O operations are delegated to libuv, so the thread is free to process other requests while waiting for I/O to complete.
Because it uses far less memory than thread-per-request. One thread serves thousands of connections. The trade-off is that CPU-heavy work on the main thread blocks everything, which is why Node.js is best for I/O-bound work.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.