Concurrency in Node.js
Node has a reputation for being "single-threaded", which confuses people: how does a single thread serve thousands of simultaneous connections? The answer is that Node achieves concurrency (making progress on many tasks) without parallelism (running many tasks at the exact same instant) — through its asynchronous, non-blocking event loop. When you do need true parallelism for CPU-bound work or to use every core, Node gives you worker threads, child processes, and the cluster module. This page draws the crucial distinctions and maps out which tool fits which job.
Concurrency vs parallelism — not the same thing
Concurrency | Parallelism | |
|---|---|---|
Definition | Dealing with many things at once (interleaved) | Doing many things at the same instant |
Needs | One thread + task switching | Multiple cores/threads running simultaneously |
Node default | Yes — via the async event loop | No — single thread runs your JS |
Analogy | One chef juggling several dishes | Several chefs each cooking a dish |
How one thread serves thousands of connections
Single thread + event loop + async I/O:
Request A ──▶ start DB query ──┐ (thread is FREE while DB works)
Request B ──▶ start API call ──┤ (thread is FREE while API responds)
Request C ──▶ start file read ─┤ (thread is FREE while disk reads)
│
DB result ready ◀──────────────┘ thread picks it up, finishes A
API result ready ◀────────────── thread picks it up, finishes B
→ The thread is only busy *dispatching* and *processing results*,
never *waiting*. That's how one thread handles 10,000 connections.The limits of one thread
Choosing the right tool
Tool | Gives you | Best for | Memory model |
|---|---|---|---|
Async/await | Concurrency, no parallelism | I/O-bound work (the default) | Shared (one thread) |
Worker threads | Parallelism within one process | CPU-bound tasks (compute, crypto) | Isolated; share via |
Cluster | Parallelism across processes | Scaling an HTTP server across cores | Fully isolated processes |
Child process | Run a separate program | Shelling out, isolating risky work | Fully isolated processes |