Skip to content
Knowledge Hub

Node.js runtime Basic

Many performance problems in a Node.js service are not in the database or the network, but in a piece of JavaScript holding the main thread, or in data arriving faster than its destination can write it. This section gathers three foundations of the runtime.

Scope of this section: only the Node.js runtime. There are no TypeScript articles yet (type system, tsconfig configuration, builds); they will be added here when they exist.

Order Article Level Question it answers
1 Node.js event loop Intermediate In what order do callbacks run, why are timers late, what blocks the main thread?
2 Streams and backpressure Intermediate What happens to memory when data arrives faster than the destination writes?
3 AsyncLocalStorage Intermediate How do you keep a requestId or tenant per request when many requests interleave?
Symptom Start with
Every route is slow at the same time, even the one that returns pong Event loop (the main thread is occupied)
setTimeout(fn, 0) runs late or the setImmediate order is hard to predict Event loop
RSS grows with the number of uploads or slow clients Streams and backpressure
Logs from one request carry another request’s requestId AsyncLocalStorage

If you use NestJS, the request lifecycle and provider scopes assume the model above: a CPU-bound handler slows every request in the same process, no matter how the pipeline is configured.