performance-observabilityAnswer last reviewed July 2026

If you could only watch one metric to catch a Node process going bad before users notice, what would it be? And how do you measure it properly?

A strong answer picks event-loop delay as the metric that moves first when a Node process goes bad, and measures it as a histogram instead of an average

What an AI-prepared candidate might say

I'd say event-loop lag, or event-loop delay, same thing. Node runs your JavaScript on a single thread, so if anything blocks the event loop, every request gets delayed, and the thing is CPU and memory can still look totally fine while that's happening. So watching the lag tells you when the loop is falling behind. You measure it with perf_hooks, there's a monitorEventLoopDelay function that records the delay into a histogram. If the lag is rising it means the loop can't get to events promptly, usually because of synchronous or CPU-heavy work somewhere. You'd set an alert threshold, maybe tens of milliseconds or something like that, and investigate when it crosses. The usual fix is moving the blocking work off the main thread, into a worker thread or an async operation. It catches problems the CPU and memory graphs just miss, so it's the one to watch first.

Senior
Locked

Why event-loop delay beats CPU at predicting the latency users feel, how `monitorEventLoopDelay` builds its histogram, and what it means when p99 lag starts climbing.

Unlock the depth
Staff
Locked

How to pick a threshold that catches real stalls without crying wolf, tying lag spikes back to the synchronous code behind them, and why 'add more CPU' almost never fixes it.

Unlock the depth
Follow-up chain
If you could only watch one metric to catch a Node process going bad before users notice, what would it be? And how do you measure it properly? | NodeBook