Skip to main content

Node.js Isn't Fast at Math — It's Fast at Waiting

Non-blocking I/O, event-driven architecture, concurrency vs parallelism, and where Node.js shines for web applications

Updated 8 min readMarkdown
Node.js Isn't Fast at Math — It's Fast at Waiting

Say "Node.js is fast" to a backend engineer and they will ask: fast at what?

If you ask Node.js to encode video or crunch giant matrices, languages like Rust, Go, or C++ are usually faster at CPU-heavy work. Yet web apps rarely spend their time doing heavy math. They spend most of their time waiting — waiting on databases, waiting on third-party APIs, waiting on disk reads. That is where Node.js earns its reputation.

Watch five simulated 100ms I/O tasks run one at a time versus concurrently on Node.js 24.22.1:

// Constructed example simulating a 100ms I/O call (DB query or API fetch)
function fakeIoTask(id) {
  return new Promise((resolve) => {
    setTimeout(() => resolve(`task-${id} done`), 100);
  });
}

async function run() {
  const t1 = Date.now();
  for (let i = 1; i <= 5; i++) {
    await fakeIoTask(i);
  }
  console.log(`One at a time (5 tasks): ${Date.now() - t1}ms`);

  const t2 = Date.now();
  await Promise.all([1, 2, 3, 4, 5].map((i) => fakeIoTask(i)));
  console.log(`Concurrently (5 tasks):  ${Date.now() - t2}ms`);
}
run();
One at a time (5 tasks): 549ms
Concurrently (5 tasks):  109ms

Same single JavaScript thread, same five 100ms waits, nearly five times faster when the waits overlap. This post explains the behavior behind that result — without hand-wavy hype or synthetic benchmarks.

The restaurant-order analogy

Picture a busy restaurant with one waiter and a kitchen behind a swinging door.

If the waiter took table 1's order, walked to the kitchen, and stood staring at the stove for 15 minutes until the pasta cooked, tables 2 through 5 would sit untouched.

Instead, the waiter takes table 1's order, clips the ticket to the kitchen rail, and walks straight to table 2. When the chef rings the bell, the waiter picks up whichever dish is ready first and serves it.

In Node.js, your JavaScript code is that single waiter. The operating system and background I/O layer are the kitchen. The bell is an event.

What makes Node.js fast for web applications

Three design choices work together:

  1. V8 JIT-compiles JavaScript to machine code. Node.js runs on Chrome's V8 engine, which runs bytecode first for fast startup and JIT-compiles hot functions into native machine code.
  2. Non-blocking I/O. When your code reads a file, queries a database, or calls an HTTP endpoint, Node.js hands the wait to the OS (or libuv's background thread pool) and immediately moves to the next request. If you want the sync vs async fundamentals first, see synchronous vs asynchronous JavaScript.
  3. Event-driven architecture. Instead of polling in a loop asking "is the data ready yet?", your code registers a listener or callback and Node.js notifies you when the event fires.

Here is that restaurant-bell pattern using Node's built-in EventEmitter:

const EventEmitter = require("events");

const kitchen = new EventEmitter();

kitchen.on("orderReady", (table, dish) => {
  console.log(`Serve ${dish} to table ${table}`);
});

console.log("Waiter takes order for table 1");
setTimeout(() => kitchen.emit("orderReady", 1, "pasta"), 80);

console.log("Waiter takes order for table 2");
setTimeout(() => kitchen.emit("orderReady", 2, "soup"), 30);
Waiter takes order for table 1
Waiter takes order for table 2
Serve soup to table 2
Serve pasta to table 1

Table 2's soup arrived first even though table 1 ordered first. Nothing sat idle waiting for pasta.

Single-threaded model vs blocking servers

Many traditional web servers handle concurrency by assigning one OS thread per incoming request. While Request A waits on a database query, Thread 1 sits paused and the server spawns Thread 2 for Request B. That works well until thousands of concurrent users connect at once: each thread consumes memory, and the OS spends time switching between them.

Node.js takes the opposite trade-off. One main JavaScript thread accepts every request, kicks off its I/O asynchronously, and switches to the next request without spawning a new JavaScript thread for each user.

Blocking server vs Node.js request handling: in a blocking thread-per-request server, Request 1 holds Thread 1 idle during a DB wait while Request 2 needs Thread 2; in Node.js, one single thread receives Request 1 and Request 2 and hands both DB waits off to the OS asynchronously

That single thread is coordinated by the event loop. Each time a background I/O operation finishes, its callback enters a queue. Whenever the main thread finishes its current work, the event loop pulls the next ready callback and runs it.

Event loop request processing visualization: incoming HTTP requests enter the single JavaScript thread, async I/O work is handed off to the OS or background workers, completed callbacks wait in the event queue, and the event loop feeds them back to the main thread to send responses

Concurrency vs parallelism

Beginners often mix these two words up, and the difference explains why a single-threaded runtime can still serve many users at once:

  • Concurrency is dealing with many tasks at once by switching between them while they wait. One waiter serving five tables is concurrent.
  • Parallelism is doing multiple tasks at the exact same instant on multiple CPU cores. Five waiters taking five orders at the same second is parallel.

Node.js gives you concurrency on one JavaScript thread by overlapping I/O waits, while the OS and external databases handle those waits in parallel. It does not run two pieces of your JavaScript code in parallel on that main thread — which is why one long synchronous loop stalls every other request.

Where Node.js performs best — and who uses it

Node.js fits workloads that are I/O-bound: lots of network calls, database queries, and lightweight JSON shaping per request.

  • REST and GraphQL APIs: routing requests, validating input, querying a database, and returning JSON.
  • Backend-for-Frontend (BFF) layers: aggregating calls to several internal microservices into one payload tailored for a web or mobile client.
  • Real-time apps: chat servers, live notifications, and collaborative dashboards over WebSockets, where many open connections sit mostly idle waiting for the next message.
  • API gateways and proxies: forwarding traffic, checking auth tokens, and logging with low per-connection memory overhead.

Several well-known companies have publicly described moving web-facing code to Node.js. The reasons and numbers below are the companies' own statements as reported by InfoQ, not independent benchmarks:

  • PayPal moved its web application development from Java/JSP to Node.js, starting around 2013. InfoQ's summary of PayPal's engineering posts gives the reasons: accumulated technical debt, and a divide between front-end engineers and Java back-end engineers that made it hard to move prototypes into production.
  • LinkedIn replaced the Ruby on Rails back end of its mobile service with Node.js. Its director of mobile engineering said the Rails back end had scalability problems and claimed Node.js was up to 20x faster in some scenarios, with 3 servers doing the work of 30. A former team member disputed how fair that comparison was (InfoQ).
  • Netflix moved its website UI to Node.js. A Netflix engineer wrote about tracing a steadily rising request latency during that move, which ended with the team replacing the API framework underneath (InfoQ).

My reading, not something those reports state: the common thread is the web tier, the part of a system that spends most of its time waiting on other services, not the databases or video encoders behind it.

When NOT to use Node.js

Node.js is not "perfect" for every backend job. Skip it — or offload the heavy work — when your workload is CPU-bound:

  • Video or audio transcoding, heavy image resizing, or PDF rendering at scale.
  • Machine learning model training and heavy numerical computation.
  • Large synchronous parsing or cryptographic work on the main request thread.

Because JavaScript runs on one main thread, any task that keeps the CPU busy for 300ms freezes every other user's request for those 300ms. If a Node.js app occasionally needs CPU work, push it to a background job queue, Worker Threads, or a separate service written in a language built for parallel CPU throughput.

Where this leaves you

Node.js feels fast for web applications because web applications mostly wait on I/O, and non-blocking, event-driven concurrency turns that waiting time into useful work for other users. Match it to I/O-heavy APIs, BFF layers, and real-time servers, and keep heavy CPU loops off the main thread.

One honest limit: this post focused on execution behavior rather than load-test benchmarks, the company examples rest on the linked public reports (I did not verify them independently), and it did not cover scaling across multiple CPU cores with Node's cluster module, Worker Threads, or running multiple container replicas behind a load balancer. What kind of workload are you building with Node.js right now — an I/O-heavy API, a real-time app, or something with CPU-heavy steps?

No comments yet. Be the first to comment.