Zero-downtime deployment is a release practice in which a new version of an application replaces the old one without any interruption of service visible to users: no maintenance window, no failed requests and no lost sessions. In DevOps and in the Cloud subject more broadly, it is a core capability of continuous delivery, because teams that deploy many times per day cannot afford an outage for each release.
The approach rests on three ideas: running old and new versions side by side, shifting traffic gradually or atomically between them, and keeping every change backward compatible long enough for both versions to coexist. Strategies such as rolling, blue-green and canary deployment are concrete implementations of this goal.
How zero-downtime deployment keeps a service available
A zero-downtime deployment works by ensuring that healthy capacity always exceeds demand during the change. New instances are started, verified by health checks, and only then added to the load balancer, while old instances are removed only after they stop receiving traffic and finish their in-flight requests.
The final step, connection draining, is often overlooked. An instance about to stop first leaves the load balancer pool, then waits for a grace period, commonly 30 to 60 seconds, before the process exits. Without draining, users experience reset connections and failed requests even when enough capacity exists.
The following table summarizes the building blocks that a deployment pipeline must provide.
| Building block | Purpose | Failure if missing |
|---|---|---|
| Redundant instances | Serve traffic while others are replaced | Capacity gap during rollout |
| Readiness checks | Admit only instances able to serve | Requests reach unready processes |
| Load balancer control | Shift traffic between versions | No way to steer users |
| Graceful shutdown | Finish in-flight work before exit | Dropped requests and broken sessions |
| Automated rollback | Restore the previous version quickly | Long recovery after a bad release |
| Compatible schema changes | Let both versions use the same data | Errors in the old or new version |
Deployment strategies that achieve zero downtime
Several strategies deliver zero downtime, and they differ mainly in cost, speed of rollback and exposure to risk. The choice depends on infrastructure budget, traffic volume and how much real-user validation a team wants before a full release.
| Strategy | Mechanism | Extra capacity | Rollback speed |
|---|---|---|---|
| Rolling deployment | Replace instances in small batches | Low, often one batch | Moderate; requires reverse rollout |
| Blue-green deployment | Switch all traffic to an idle copy | High, about double | Very fast; switch back |
| Canary deployment | Send a small share of traffic first | Low to moderate | Fast; stop the canary |
| Feature flags | Deploy dark, enable code at runtime | None beyond normal | Instant; turn flag off |
| Shadow traffic | Mirror requests to the new version | Moderate | Not needed; users unaffected |
In practice teams combine them. A common pattern is a rolling update with a canary phase: the first few percent of traffic reaches the new version, automated analysis compares error rates and latency, and the rollout continues only if the metrics stay within thresholds.
Database and state changes without downtime
The hardest part of zero-downtime deployment is usually data, not code. Because old and new versions run at the same time, every database change must work with both. The established technique is the expand and contract pattern, also called parallel change.
- Expand: add new columns or tables without removing old ones, and make new fields nullable or defaulted.
- Migrate: deploy code that writes to both structures and backfill existing data in small batches.
- Switch reads: release a version that reads only from the new structure.
- Contract: remove the old columns in a later release, once no running version depends on them.
The table below shows how typical schema changes are made safe.
| Change | Unsafe approach | Zero-downtime approach |
|---|---|---|
| Rename a column | Rename in one migration | Add new column, dual-write, drop old later |
| Add a required field | Add NOT NULL without default | Add nullable, backfill, then enforce |
| Remove a column | Drop together with code change | Stop using it first, drop in next release |
| Large index build | Blocking index creation | Online or concurrent index creation |
Long-lived connections, caches and message formats need the same discipline. Queue consumers must tolerate both message versions, and session data should live in a shared store rather than in instance memory, so users are not logged out when their instance is replaced.
Zero-downtime deployment on Kubernetes and cloud platforms
Cloud platforms provide most of the primitives, but correct configuration remains the team’s responsibility. On Kubernetes, a Deployment performs rolling updates controlled by the maxUnavailable and maxSurge settings; setting maxUnavailable to 0 guarantees that serving capacity never drops below the desired replica count.
- Readiness probes must reflect true ability to serve, including warm caches and dependency connections.
- A preStop hook with a short sleep gives load balancers time to remove the endpoint before shutdown.
- PodDisruptionBudgets protect availability during node maintenance as well as during releases.
- Managed load balancers need matching deregistration delays so that draining completes.
Tools built on GitOps, such as Argo CD with progressive delivery extensions, automate canary analysis and promote or abort releases from metrics rather than human judgment.
Limitations and common mistakes
Zero downtime is an engineering target, not an absolute guarantee. Some changes, such as major database engine upgrades or breaking protocol changes with external clients, may still require coordinated windows or a long migration path.
| Mistake | Consequence | Prevention |
|---|---|---|
| Liveness probe used as readiness | Traffic hits starting instances | Separate readiness and liveness checks |
| No graceful shutdown handling | 5xx errors at every release | Handle SIGTERM and drain connections |
| Breaking schema change with code | Old instances fail during rollout | Apply expand and contract |
| Rollback never tested | Slow recovery during an incident | Rehearse rollback in staging |
| Monitoring only averages | Canary regressions go unnoticed | Compare error rates and latency percentiles |
Teams also underestimate cost and complexity: blue-green doubles infrastructure temporarily, and supporting two versions at once constrains how quickly APIs and data models can evolve.
In everyday language
Imagine a busy restaurant that renovates its kitchen without ever closing its doors. The staff set up a second cooking station, test it with a few dishes, and move the cooks over one by one. Guests keep getting their meals and never notice the change.
Zero-downtime deployment does the same for software. The new version is prepared next to the old one, checked carefully, and then given the work step by step. The key point is that users are never turned away while the update happens.
Seen in the real world
A payments company releases its transaction API around fifteen times per week. The service runs as 20 replicas on a Kubernetes cluster behind a cloud load balancer, with maxSurge at 25 percent and maxUnavailable at 0, and each Pod drains connections for 45 seconds before exiting.
Each release starts as a canary receiving 5 percent of traffic for ten minutes. An automated analysis compares the canary’s error rate and 99th percentile latency with the stable version. A recent release that added a currency field used the expand and contract pattern: the column was added as nullable one week, backfilled, and enforced the following week.
When one canary showed a rise in timeouts caused by a misconfigured connection pool, the pipeline aborted the rollout automatically within minutes. Customers saw no failed payments, and the team fixed and redeployed the change the same afternoon.