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.
How to Use This List
- Link each service wiki page to rollback command and owner
- Run quarterly game day using On-Call Runbook Starters
- Pair with Platform Deploy Best Practices for rollout settings
-
SIGTERM graceful shutdown:
server.close()then close pools - Graceful Shutdown. -
Fail readiness while draining: 503 on
/readyduring shutdown. -
preStop + app drain aligned: K8s sleep before SIGTERM - Zero-Downtime Deploys.
-
Forced exit timeout: Exit 1 if drain exceeds grace period.
-
uncaughtExceptionpolicy 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 undoor 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
onClosehooks: 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
/healthprobe from outside cluster. -
Do not profile production casually: Reproduce in staging with load replay.
FAQs
What is the single highest-impact runtime ops practice?
Graceful SIGTERM shutdown with readiness drain. Eliminates the majority of deploy-related 502 incidents.
Should APIs ever continue after uncaughtException?
Rarely. Document an exception in the service runbook if process state is provably safe (almost never for HTTP).
How long should on-call runbooks be?
Two pages per common alert. Link to deep docs; on-call needs commands and decision tree, not essays.
Lambda runtime ops?
Focus on cold start, timeout, and callbackWaitsForEmptyEventLoop - Serverless Best Practices.
Who updates runbooks?
Service owner after every SEV2+ incident or drill finding.
Related
- Runtime Ops Basics - supervision intro
- Graceful Shutdown - SIGTERM pattern
- Zero-Downtime Deploys - rolling deploys
- On-Call Runbook Starters - incident triage
- Docker Best Practices - image and probe checklist
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.