Runtime Ops Best Practices
A condensed summary of the 25 most important runtime ops practices for Node.js teams - drawn from every page in this section.
Search across all documentation pages
A condensed summary of the 25 most important runtime ops practices for Node.js teams - drawn from every page in this section.
SIGTERM graceful shutdown: server.close() then close pools - Graceful Shutdown.
Fail readiness while draining: 503 on /ready during shutdown.
preStop + app drain aligned: K8s sleep before SIGTERM - Zero-Downtime Deploys.
Forced exit timeout: Exit 1 if drain exceeds grace period.
uncaughtException policy documented: Default exit for HTTP APIs - Runtime Ops Basics.
unhandledRejection -> exit: Same as uncaught for API services.
No PM2 inside K8s: One process per container; platform scales replicas.
PM2/systemd on VMs only: When not containerized - PM2 & systemd.
Bind 0.0.0.0: Prevents LB 502 to listening-on-localhost only.
Logs to stdout JSON: requestId, method, path, status, duration.
Never log secrets or full bodies: PII compliance.
NODE_OPTIONS --max-old-space-size: ~75% of container memory limit.
Memory limit headroom: OOMKill investigation before blind limit bump.
CPU troubleshooting: Distinguish traffic spike vs deploy vs tight loop.
Rollback first when deploy correlated: kubectl rollout undo or previous SHA.
Separate liveness and readiness triage: 502 often readiness or drain.
ALB/Ingress timeout > app p99: Prevents proxy 502 on slow requests.
Close BullMQ/Redis/cron on shutdown: Not only HTTP server.
NestJS enableShutdownHooks: Module destroy order.
Fastify onClose hooks: Pool and Redis cleanup.
Boot log with Node version and pid: Confirms correct image after deploy.
On-call runbooks maintained: High CPU, memory, 502 starters updated after incidents.
Postmortems blameless: Action items tracked in ticketing system.
Synthetic monitoring: 1-minute /health probe from outside cluster.
Do not profile production casually: Reproduce in staging with load replay.
Graceful SIGTERM shutdown with readiness drain. Eliminates the majority of deploy-related 502 incidents.
Rarely. Document an exception in the service runbook if process state is provably safe (almost never for HTTP).
Two pages per common alert. Link to deep docs; on-call needs commands and decision tree, not essays.
Focus on cold start, timeout, and callbackWaitsForEmptyEventLoop - Serverless Best Practices.
Service owner after every SEV2+ incident or drill finding.
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