Node.jsInterview preparation
Intermediate·Concept·2 min read

How can Node handle many requests with one JavaScript thread?

Practice this question

Definition:

Node.js is a JavaScript runtime designed to handle many operations that spend time waiting for I/O. It lets the operating system and supporting runtime facilities wait for work, then runs ready JavaScript callbacks on an event-loop thread. This makes one process useful for many concurrent connections without one JavaScript thread per request.

Key points:

  • Network I/O waits outside the JavaScript thread using the OS and libuv.

  • The event loop runs callbacks when work is ready.

  • Heavy synchronous work still blocks other requests on that thread.

  • Concurrency means multiple requests are in progress; it does not mean their JavaScript runs simultaneously on the same thread.

Interview point:

  • Describe what happens while a database request waits, and contrast that with a CPU-heavy loop occupying the thread.
Adapted from 02_NODE_EXPRESS_HTTP.md · “How can Node handle many requests with one JavaScript thread?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.