The Happy Path logo: a checkmark inside curly braces

The Happy Path Newsletter

Archives
Follow on X
Log in
Subscribe
November 29, 2026

How one Node.js thread handles thousands of requests.

The event loop, built up one diagram at a time, plus the one thing that blocks it.

Welcome to the first Happy Path newsletter issue.

Node.js executes JavaScript on a single thread. A single Node server still handles thousands of requests at the same time. How is this possible? The event loop.

The short version fits in one picture:

The full flow: requests come in, slow work is handed off, and finished work comes back as a callback.

The rest of this email builds that picture one step at a time.

Step 1: what a server does

A web server is a program that waits for requests and sends back responses. With Node, the server is JavaScript code (often an Express app), and Node is the runtime that executes it. Most of a request's time is spent waiting: on a database, a file, another API.

Node.js is the runtime. The web server is the code it executes.

Step 2: one worker

Node executes JavaScript on a single thread, one line at a time.

The thread works on Request 1. Requests 2 and 3 wait.

Step 3: a slow task arrives

A database query or a file read. Node hands it off instead of waiting for it.

The query moves to the Background box. The thread doesn't wait for the result.

Step 4: meanwhile

The next request is executed, so the thread doesn't sit idle.

The thread moves on to Request 2 while the database query is still in progress.

Step 5: the task finishes

Its callback joins a queue.

The query is done, and onResult for Request 1 is now in the callback queue. Meanwhile, the thread has moved on to Request 3.

Step 6: the event loop

When the thread is free, it picks the next callback from the queue. That’s the event loop.

Requests 2 and 3 are done. The thread takes onResult from the queue and finishes Request 1.

The catch

One long synchronous task keeps the thread busy, and the queue just waits.

hashPasswordSync keeps the thread busy for 2 seconds. The callbacks for Requests 2 and 3 can't be executed until it's done.

That’s it

Thanks for reading the first issue of The Happy Path. Which topic should the next one explain? Let me know by replying to this email.

Don't miss what's next. Subscribe to The Happy Path Newsletter:
Continue the conversation:

Share this email:
Share on Twitter
Twitter
Powered by Buttondown, the easiest way to start and grow your newsletter.