A zero-downtime deployment replaces running code without users seeing errors or slowdowns. It is not one technique but a set of small practices across the app, the platform and the database. Miss one, and every deploy causes a burst of errors.

1. Run more than one instance

You cannot replace the only instance without a gap. Run at least two (preferably three) replicas, spread across nodes or zones, behind a load balancer.

2. Use rolling, blue-green or canary releases

Replace instances gradually, or switch traffic between two environments. Each strategy has trade-offs; see blue-green vs canary vs rolling deployments.

strategy:
  type: RollingUpdate
  rollingUpdate:
    maxUnavailable: 0     # never remove a pod before its replacement is ready
    maxSurge: 25%

3. Gate traffic on readiness

New instances must not receive traffic until they can serve it: configuration loaded, connections open, caches warmed. A readiness endpoint that reflects this is essential; see health check endpoints.

4. Shut down gracefully

Old instances must finish in-flight requests and stop receiving new ones before they exit. See graceful shutdown in Kubernetes.

5. Keep changes backward compatible

During a rolling deploy, old and new versions run at the same time and talk to the same database, queues and clients. That means:

  • APIs: add fields, do not remove or rename them in the same release.
  • Messages: consumers must accept both old and new message shapes during the rollout.
  • Database: expand first, contract later; see zero-downtime database migrations.
  • Caches: version keys if the stored format changes.

6. Separate deploy from release

Feature flags let you deploy code dark and turn it on later, gradually, with an instant off switch. See feature flags for safe releases.

7. Warm up

JIT-compiled runtimes, cold caches and new connection pools make the first requests slow. Warm-up requests before marking ready, or slow-start in the load balancer, keep latency flat.

8. Make rollback one command

If error rates rise, roll back first and investigate later. Keep the previous version's image available and rehearse rollback.

Verifying with monitoring

You only know a deploy had zero downtime if you measure it:

  • Deploy markers on every chart: from your pipeline, GitHub or service.version in telemetry.
  • Error rate and p95 per endpoint, before and after the marker.
  • Uptime checks from several regions every minute during deploy windows.
  • Version comparison: new version's error rate and latency against the old one while both serve traffic.

Worked example

A team's deploys caused about 30 seconds of elevated 502s. Investigation showed three gaps: maxUnavailable: 1 removed a pod before its replacement was ready, the app exited immediately on SIGTERM, and the JVM's first requests took 3 seconds. They set maxUnavailable: 0, added graceful shutdown with a preStop delay, and sent warm-up requests before readiness passed. The next twenty deploys showed no change in error rate at the deploy markers.

The checklist

  1. Two or more replicas across nodes or zones.
  2. Rolling update with maxUnavailable 0 (or blue-green/canary).
  3. Readiness gates traffic; startup probes for slow starts.
  4. Graceful shutdown with preStop delay.
  5. Backward-compatible APIs, messages and schemas.
  6. Feature flags for risky behaviour changes.
  7. Warm-up before serving.
  8. One-command rollback, rehearsed.
  9. Deploy markers and version comparison in APM.
  10. Uptime checks watching every deploy.

VitalRix shows deploy markers on APM charts, compares versions, and groups new errors by the version they first appeared in with error tracking.

Common mistakes

  • maxUnavailable above zero for small deployments, removing capacity before replacements are ready.
  • Readiness that passes before the app is warm, so the first users after each deploy hit slow responses.
  • Breaking API or message changes shipped in one release, failing the old version still running.
  • Long-running jobs killed by deploys, because the grace period is shorter than the job.
  • No monitoring at deploy time, so a small error burst every deploy goes unnoticed for months.

Measuring deploy quality

Track, per deploy: error rate in the 10 minutes after compared with the 10 minutes before, p95 latency change, and whether any new error group appeared. Plotting these over a quarter shows whether deploys are getting safer.

Questions to ask before every deploy

Is this change backward compatible with the version still running? Does it include a migration, and is it the expand or the contract step? Is there a flag to turn the new behaviour off? Who is watching the dashboards for the next ten minutes, and what would make them roll back?

Is zero downtime possible with one server?

Only with tricks such as running the new version alongside the old one on the same machine and switching the proxy. Two or more instances is far simpler.

Do database migrations cause downtime?

They can, if they lock tables or break the running version. Expand-and-contract migrations avoid both.

How do I know a deploy caused errors?

Compare error rate and latency around deploy markers, and compare the new version with the old one while both run.

Try VitalRix free

Uptime monitoring, APM, logs, real user monitoring and status pages in one place. No credit card needed.