Node.js runs JavaScript on a single thread. How can it serve thousands of connections at once? What kinds of workloads suit Node, and which do not?
Show the explanation
Model answer. Your JavaScript runs on one main thread, but I/O is non-blocking. When a request needs the database, a file or another API, Node hands that work to the operating system (or libuv's small thread pool for things like file access, DNS and crypto), registers a callback, and immediately moves on to the next request. When the I/O completes, the event loop runs the callback. One thread can therefore juggle many connections that are mostly waiting.
Good fit (I/O-bound):
- REST and GraphQL APIs, backends-for-frontends
- real-time apps: chat, notifications, WebSockets
- streaming and proxies
- tooling (bundlers, CLIs)
Poor fit (CPU-bound):
- video encoding, image processing, heavy number crunching, large report generation
A CPU-heavy task blocks the event loop: every other request waits until it finishes. Work around it with worker_threads, by moving the job to a queue processed by separate workers, or by using a language better suited to the task.
Original UniCircle question. Last reviewed 22 Oct 2026.
