Performance Best Practices
Profile production-like concurrency, not hello-world curls. These rules keep Node.js APIs fast under real traffic.
Search across all documentation pages
Profile production-like concurrency, not hello-world curls. These rules keep Node.js APIs fast under real traffic.
monitorEventLoopDelay. Loop lag predicts user pain early.limit: "1mb" or stricter). Reject abuse before JSON.parse runs.*Sync fs and crypto APIs in HTTP handlers. Use promise/async variants.pino-pretty during profiling. Log I/O skews clinic and load results.--max-old-space-size. Snapshots in staging, not guesswork.Promise.all. Serial await chains add latency linearly.p95 request latency at expected concurrency, plus error rate. CPU alone misleads when you are I/O bound.
When you have no baseline, no SLO, and no user-reported pain. Measure first.
Prioritize high-RPS read endpoints and large list responses. Low-traffic admin routes can wait.
Smoke on every deploy to staging; full stress nightly or before major releases.
Helps connection reuse; does not fix sync JSON or serial DB calls. Profile the handler.
Redis/CDN caching is valid - still slim origin responses and set TTLs. Cache stampede needs separate guards.
Same rules apply. Watch interceptors and class serialization - prefer explicit DTOs and Fastify adapter for hot paths.
When Flame shows framework overhead is small vs your sync handler work, fix handlers first. When Express limits are hit after tuning, see Fastify ADR.
Stack versions: This page was written for Node.js 24.18.0 (Active LTS), npm 10+, TypeScript 5.6+, Express 5, Fastify 5, and NestJS 11.
Reviewed by Chris St. John·Last updated Jul 16, 2026