InterviewHubPRO
Section Overview
Q12

Question 12 of 60

Part 2: Runtime Internals, Libuv & The Event Loop (6 - 20)

20%
Node.js & Libuv•Part 2: Runtime Internals, Libuv & The Event Loop (6 - 20)

Detecting Event Loop delay in production.

In Simple Words: Use the perf_hooks built-in module to measure p99 Event Loop lag:

javascript
const { monitorEventLoopDelay } = require('perf_hooks');
const histogram = monitorEventLoopDelay({ resolution: 20 });
histogram.enable();

setInterval(() => {
  const p99 = (histogram.percentile(99) / 1e6).toFixed(2);
  console.log(`Event Loop p99 delay: ${p99} ms`);
  histogram.reset();
}, 5000);