Skip to the page

Scaling and running in production · mid

Deploying a Node service

A deployable Node service is a pinned-LTS container image built in CI, configured only through environment variables and a secrets manager, with health checks, graceful shutdown and database migrations run as a separate step, rolled out gradually so a bad version can be rolled back fast.

The notes

What you must know

  • Build once in CI (install with npm ci, test, build an image tagged with the git SHA), deploy the same artifact to staging and production.
  • Config through environment variables (twelve-factor); secrets from a secrets manager (AWS Secrets Manager or SSM Parameter Store, Vault), never in the image or git.
  • Run Node directly in the container (CMD ["node", "dist/server.js"]) as a non-root user, with NODE_ENV=production; handle SIGTERM.
  • Health endpoints: liveness (process OK) and readiness (DB and Redis reachable, ready for traffic).
  • Rollouts: rolling update, blue/green or canary; watch error rate and latency, roll back automatically on failure.
  • Migrations: run them as a separate step before the new code starts, and only backward-compatible ones (expand and contract), so old and new versions can run side by side.
  • Platforms: ECS/Fargate, Kubernetes, Render/Railway/Fly.io, or Lambda; Vercel for Next.js. Docker and AWS details are in their own tracks.

The red pen

Common traps: mistake → fix

  • Mistake: Rebuild the image for each environment

    Fix: you test one artifact and ship another; promote the same image.

  • Mistake: Put secrets in .env inside the image

    Fix: anyone with the image can read them.

Easy to hard

Questions interviewers ask, easy to hard

  1. How do you deploy your Node service today?
  2. How do you handle configuration and secrets per environment?
  3. How do you deploy without downtime, including database migrations?
  4. A deploy doubles the error rate. What happens next?

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview