← Back to Node.js performance maplag
🔄
Node.js Performance
Event Loop Lag
Detect main-thread blocking, the most common Node latency killer.
Detailed Description
Node.js runs JavaScript on a single main event loop. If synchronous work blocks that loop, every request, timer, callback, and promise continuation waits behind it.
Event-loop lag is one of the most important Node-specific signals. High lag often points to CPU-heavy loops, synchronous crypto, huge JSON parsing, large array transforms, or garbage collection pressure.
Mental Model
set timer -> expected time -> actual time -> lag = drift
When To Use
- ->Detect CPU-bound synchronous work
- ->Catch large JSON.parse or crypto blocking
- ->Alert before users see timeouts
Tools: perf_hooks monitorEventLoopDelay, timer drift detector
event-loop-lag.js
Live Editor
Loading...
Output
Run code to see output...