Ask anything about this article
Hi! I've read this article.
What would you like to know?
@farhan

The headline "Node.js Isn't Single-Threaded" exploded on Hacker News and Dev.to today, and the conversation is already heating up. For years developers have been taught that Node.js runs JavaScript on a single thread, using an event loop to achieve concurrency. The reality is more nuanced: libuv, the C library that powers Node, manages a hidden thread pool and leverages OS kernel primitives to keep the event loop fast. In this post we unpack the true execution model, compare it to recent news about Python's experimental JIT being removed, and give you actionable takeaways.
"Understanding the real thread model is the only way to make informed performance decisions."
Most tutorials start with a simple diagram: one JavaScript thread, an event loop, callbacks. That picture is useful for beginners, but it hides the complexity that matters to production engineers.
The myth persists because the event loop appears single-threaded. When you call fs.readFile, the call returns immediately, and the callback runs later. The underlying work, however, is happening on a different thread.
libuv is the glue between JavaScript and the operating system. It maintains a default thread pool of four threads (configurable via UV_THREADPOOL_SIZE). These threads handle:
uv_queue_workWhen you invoke an async API, libuv places a task in the queue, wakes a worker thread, and notifies the event loop when the work is done. This design gives Node the ability to process many I/O operations concurrently without blocking the main JavaScript thread.
| Setting | Default | Typical Use Case |
|---|---|---|
| %%INLINECODE_3%% | 4 threads | General web services |
| %%INLINECODE_4%% | 4 threads | Heavy file processing |
| %%INLINECODE_5%% | 4 threads | Debugging race conditions |
Increasing the pool size can improve throughput for I/O‑heavy workloads, but it also consumes more memory and can cause context‑switch overhead. The sweet spot depends on the ratio of I/O to CPU work.
Beyond libuv's thread pool, Node relies on kernel mechanisms like epoll (Linux), kqueue (BSD/macOS), and IOCP (Windows) to monitor file descriptors. These mechanisms are edge‑triggered, meaning the kernel tells the event loop when a descriptor becomes ready, and the loop then processes the event.
io_uring (experimental) for even lower overhead.The combination of a thread pool for blocking syscalls and kernel‑level non‑blocking APIs creates a hybrid model that is far from "single‑threaded".
Understanding this model changes how you approach performance tuning.
setImmediate does not move it off the main thread.UV_THREADPOOL_SIZE to match the number of concurrent disk operations.worker_threads module. Use it for image processing, encryption, or heavy calculations.clinic.js expose libuv thread pool queue length, helping you spot bottlenecks.A fintech startup migrated a monolithic Java service to a Node.js API gateway. Initially they hit latency spikes at 10k RPS because the default thread pool saturated with TLS handshakes. By raising UV_THREADPOOL_SIZE to 12 and offloading JWT verification to worker threads, they cut 99th‑percentile latency from 250ms to 80ms.
While Node.js is clarifying its concurrency model, Python announced the removal of its experimental JIT (PEP 709). The two events intersect in a surprising way:
| Feature | Node.js | Python |
|---|---|---|
| Concurrency Model | Event loop + libuv thread pool + optional worker threads | GIL‑protected interpreter + async/await + optional multiprocessing |
| Recent Change | Public clarification that Node is not truly single‑threaded | Removal of experimental JIT, reverting to interpreter‑only execution |
| Developer Impact | Need to understand hidden threads for I/O scaling | Loss of potential speedup for compute‑heavy code; more reliance on C extensions |
Both ecosystems are confronting myths that affect performance expectations. Node developers must now consider thread pool sizing, while Python developers may need to revisit Cython or native extensions to compensate for the missing JIT.
UV_THREADPOOL_SIZE and NODE_OPTIONS=--max-old-space-size should be part of your Dockerfile or CI config.io_uring support may become default in Node 20+, further reducing kernel‑space overhead.The headline "Node.js Isn't Single-Threaded" is less a scandal and more a long‑overdue correction. The runtime has always been a hybrid of a single JavaScript thread, a libuv thread pool, and OS‑level non‑blocking primitives. Knowing this lets you tune performance, avoid common pitfalls, and make smarter architectural choices. As the JavaScript ecosystem continues to evolve, the conversation will shift from "single‑threaded vs multi‑threaded" to "how to orchestrate the hidden threads efficiently".
Stay curious, profile relentlessly, and remember: the event loop is only one piece of the puzzle.