Performance monitoring
Node.js performance monitoring
Node.js runs your JavaScript on one thread. Anything that blocks it slows every request at once, so event loop delay is the first number to watch.
2 min read8 sectionsUpdated
On this page
| Metric | Meaning | Worry when |
|---|---|---|
| Event loop delay (p99) | How long callbacks wait to run | Above ~100 ms; everything is slower |
| Event loop utilization | Share of time the loop is busy | Near 1.0 under normal traffic |
| Heap used / heap limit | V8 memory for JS objects | Climbs and stays high after GC |
| RSS | Total process memory, including buffers | Near the container limit |
| Active handles / requests | Open sockets, timers | Grows without bound (leaked sockets) |
| Request p95 per route | User-facing latency | Above target |
import { monitorEventLoopDelay, performance } from 'node:perf_hooks';
const h = monitorEventLoopDelay({ resolution: 20 });
h.enable();
setInterval(() => {
const elu = performance.eventLoopUtilization();
console.log(JSON.stringify({ msg: 'loop', p99_ms: h.percentile(99) / 1e6, utilization: elu.utilization }));
h.reset();
}, 60_000).unref();Typical Node.js bottlenecks
- Synchronous work on the main thread:
JSON.parseof large bodies,cryptowithout async variants, regexes with catastrophic backtracking,fs.*Sync. - Unbounded concurrency:
Promise.allover thousands of items opens thousands of sockets. - Connection pools too small for pg or mysql2, so queries queue.
- Memory leaks from caches and listeners; see Node.js memory leaks.
- Unhandled promise rejections crashing the process; see unhandled promise rejection.
Instrumenting
Load the OpenTelemetry SDK before your app with node --import ./instrumentation.mjs server.js and export JSON straight to VitalRix with an API key. Step by step: Node.js tracing guide, NestJS, Next.js. For CPU profiles, node --cpu-prof writes a profile you can open in Chrome devtools as a flame graph.
Check it now, free
- Response time checker: Measure TTFB with DNS, connect, TLS and server time.
Related reading
- Node.js event loop lag: how to measure and fix it: Measure and fix Node.js event loop lag: monitorEventLoopDelay, CPU profiles, synchronous code, big JSON and worker threads, with thresholds that matter.
- OpenTelemetry for Flask: Instrument a Flask app with OpenTelemetry, in code or with zero code: trace routes, SQLAlchemy and outgoing calls, and export to VitalRix.
- Go performance monitoring: Monitor Go services: goroutine counts, GC and heap, request latency per handler, pprof profiling in production and OpenTelemetry tracing with otelhttp.
- PHP performance monitoring: Monitor PHP and Laravel apps: request latency, PHP-FPM worker saturation, OPcache hit rate, slow queries, external calls and errors.
- Python performance monitoring: Monitor Python web apps: request latency per route, worker saturation, the GIL and CPU-bound code, database time, Celery queues and memory.
- Ruby and Rails performance monitoring: Monitor Ruby on Rails apps: request latency per action, Puma thread and worker saturation, ActiveRecord queries, Sidekiq queues, memory bloat and GC.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.