Ch. 6 · Node.js

Node.js Blocking Work and Request Latency

Node.js Blocking Work and Request Latency. Learn the reasoning, a practical example, common mistakes and an interview exercise.

~2 min readbeginnerupdated Oct 3, 2026

Synchronous CPU work occupies the JavaScript thread, delaying unrelated callbacks. Asynchronous I/O alone does not make CPU-heavy processing nonblocking.

Before you start

You should know JavaScript promises, asynchronous errors and the distinction between a process and a request. When following a server example, identify the resource owner and the point where work completes. Try experiments locally with bounded input instead of assuming production traffic behaves like a single request.

The practical goal is to reason through this situation: A large JSON transformation delays every request handled by that event loop. Read the walkthrough first, then try the interview exercise before opening its answer. The important part is explaining the decision and its consequences, rather than remembering a definition alone.

Step-by-step walkthrough

Step 1: Measure competing requests

Compare a small request’s latency while another request performs a large synchronous transformation.

Step 2: Locate CPU execution

An async function still runs synchronous code on its current thread until it yields.

Step 3: Bound or move computation

Reduce algorithm cost first, then evaluate chunking or a bounded worker pool for genuinely heavy tasks.

Worked scenario

A large JSON transformation delays every request handled by that event loop.

A transformation loops over a large object before its first await. During that loop, another request’s callback waits even if its database result is already ready. Moving only the database read to asynchronous I/O leaves this bottleneck unchanged. Worker messaging and queue overhead must also be included in the comparison.

Common mistake

Adding async to a function does not move its computation to another thread.

Verify the behavior

Measure event-loop delay and p95 latency under concurrent load, then compare the same workload after the proposed change.

Interview exercise

Handle an expensive transformation.

Answer and reasoning

Reduce input and algorithm cost, chunk work or use worker threads with explicit limits.

Continue learning

Compare the scenario with the Node.js interview questions and test your understanding with the Node.js MCQs. For terminology and implementation details, consult the reference material.

More in Node.js

read ✓Node.js · hard

Node.js Clustering Across CPU Cores

Use cluster to run several workers on all cores, restart crashed workers, and understand shared-port and shared-state limits.

~2 min readread →
read ✓Node.js · hard

Node.js Password Hashing with scrypt

Store passwords as salted hashes with a slow key-derivation function, and compare candidates in constant time.

~2 min readread →
esc