Ship new code with no failed requests: draining, health gates and changes that old and new can share.
Zero-downtime deployment means users do not notice a release: no error pages, no dropped requests, no maintenance window. It is not one technique. It is a set of habits that work together.
Rolling, blue-green and canary are mechanisms for moving traffic from the old version to the new. Each of those has its own topic. Zero downtime is the outcome, and the mechanism alone does not guarantee it. A rolling update that kills servers mid-request, or sends traffic to a server still starting, still drops requests. A blue-green switch that changes the database in a breaking way still breaks the old version.
There are three things that must be true, whatever mechanism you pick:
| Need | What it means | If missing |
|---|---|---|
| Spare capacity | At least two instances, and room to lose one during the rollout | A single instance restart is an outage |
| Safe handover | Ready before traffic in, finished before traffic out | Errors during start and stop |
| Compatibility | Old and new code work with the same data and APIs at the same time | Failures from mixed versions, and rollback becomes impossible |
| Block | What it does | Detail |
|---|---|---|
| Readiness check | Tells the load balancer when a new instance can take traffic | Check the app and its needs (database, cache), not just that the process is alive |
| Connection draining | Stop new requests to an instance, let current ones finish | Set a timeout longer than your slowest normal request |
| Graceful shutdown | On a stop signal (SIGTERM), stop accepting work, finish, then exit | The app must handle the signal. Many do not by default |
| Rolling limits | Control how many instances change at once | Keep enough capacity serving. Surge a little before removing |
| Backward-compatible changes | New code works with old data and old clients | Needed because two versions run at once |
| Expand and contract | Add first, switch the code, remove last | How to change a database without breaking the old version |
| Warm-up | Fill caches and connections before taking full load | A cold instance can be slow enough to look broken |
| Mechanism | How traffic moves | It still needs |
|---|---|---|
| Rolling | Replace instances a few at a time | Draining, readiness, compatible versions |
| Blue-green | Switch all traffic between two full copies | Compatible database, warm green copy, session handling |
| Canary | Shift a small slice, then grow | Metrics to judge the slice, compatible versions |
Illustrative model: about 100 requests per step, spread evenly. Real numbers depend on traffic, request length and how many instances are taken out at once.
| Term | Meaning in easy words |
|---|---|
| Zero-downtime deployment | Releasing a new version without users noticing |
| Readiness check | A test that says an instance can take traffic |
| Liveness check | A test that says an instance is running, not stuck |
| Connection draining | Letting in-flight requests finish before an instance leaves |
| Graceful shutdown | Finishing work cleanly when told to stop |
| SIGTERM | The stop signal sent to a process before it is killed |
| Surge | Extra instances added during a rollout to keep capacity |
| Backward compatible | New code works with data and clients made for the old code |
| Expand and contract | Add the new thing, switch to it, then remove the old thing |
| Warm-up | Getting caches and connections ready before full load |
| Grace period | How long a process gets to shut down before being killed |
| Rollback | Going back to the previous version |
| Choice | We gain | We lose |
|---|---|---|
| Surge during rollout | Full capacity throughout | Brief extra cost |
| Long drain timeout | Fewer cut requests | Slower rollouts |
| Expand and contract | Safe database changes | Several releases for one change |
| Blue-green switch | Fast cutover and rollback | Double the servers for a while |
| Strict readiness check | No traffic to a half-ready server | A broken dependency can block the whole rollout |