
Your Node.js API Was Fast. Now It's Slow. Here's How to Diagnose It.
Your Node.js API was fast at launch. Three months later, P95 latency is 800ms. Traffic hasn't increased significantly. You haven't deployed anything major. The problem is somewhere in the stack — you just can't see it. This is one of the most common production Node.js scenarios. Here's a systematic approach to finding the cause. Start With the Event Loop The event loop is Node.js's heartbeat. When it stalls, everything stalls — and it stalls silently. No errors, no obvious logs, just latency creeping up. Measure it first: const { monitorEventLoopDelay } = require ( ' perf_hooks ' ); const histogram = monitorEventLoopDelay ({ resolution : 10 }); histogram . enable (); setInterval (() => { const p99 = histogram . percentile ( 99 ) / 1 e6 ; // nanoseconds to ms const p50 = histogram . percentile ( 50 ) / 1 e6 ; console . log ( `Event loop delay — p50: ${ p50 . toFixed ( 2 )} ms, p99: ${ p99 . toFixed ( 2 )} ms` ); histogram . reset (); }, 5000 ); If your event loop p99 is consistently abo
Continue reading on Dev.to
Opens in a new tab


.png&w=1200&q=75)