Why deployment strategy matters, and when to choose which
Shipping new code is widely reported as one of the most common causes of outages (a common pattern, not a figure measured here). A deployment strategy is the plan for moving users from the old version to the new one so a bad release hurts as few people as possible and can be undone quickly.
It gives you two things interviewers always ask about:
- Availability: users keep getting service while the release happens, with no downtime window.
- Safety: a bad change is caught early, affects few users, and can be rolled back fast.
Use a gradual strategy when:
- The service is user-facing and downtime or errors cost money or trust.
- You release often, so each release must be low risk.
- You can measure health (error rate, latency) to decide whether to continue.
Keep it simple (all at once) when:
- The service is internal, low traffic or has a quiet maintenance window.
- A rollout takes seconds and failure is cheap.
- The change is a tiny, well-tested configuration.
Try it
Release a new version using one of four strategies. Choose one of three kinds of release: a good one, a bad one, or one whose bug only shows at full traffic.
Deployment Strategies
Step 1 of 7 · Press Space to play, arrow keys to stepInitial state. Version 1 serves everyone. A new version 2 is about to be released.
- tick:
- 0
- users hit by errors:
- 0
- new version share (%):
- 0
- detected at tick:
- -
1 tick = one step of the simulation.
Things to try:
- Run All at once with a bad release. Everyone gets the bug, and fixing it is slow.
- Compare Rolling and Canary. A canary shows the problem to a small share first.
- Choose a release whose bug only shows at full traffic and see why a small canary is not enough. Then try Blue-green to see the instant rollback.
What to watch: the counter users hit by errors at the end of each run. The numbers are illustrative, not measurements: the simulation assumes 1,000 users per tick at full traffic, that the problem is noticed straight away, and that undoing the release takes 3 ticks for all at once, 2 for rolling, 1 for canary and 0 for blue-green. With these assumptions:
| Strategy | Bad release | Bug only at full traffic |
|---|---|---|
| All at once | 4,000 | 4,000 |
| Rolling | 750 | 3,000 |
| Canary | 100 | 2,000 |
| Blue-green | 1,000 | 1,000 |
Read the table with care. A canary limits how many users a visible bug reaches, but it cannot see a bug that needs volume. Blue-green does not limit who sees the bug, because it switches everyone at once; it only makes the way back instant. In the real world, noticing a problem also takes time, which the simulation leaves out. In the simulation the canary jumps from 5% straight to everyone, whereas the safe rollout below raises the share in several steps.
Deployment strategies
| Strategy | How it works | Good when | Weakness |
|---|---|---|---|
| All at once (recreate) | Stop the old version, start the new one everywhere | Internal tools, maintenance windows | Downtime or a risky switch, slow rollback |
| Rolling | Replace servers a few at a time | Default for stateless services | Old and new versions run together, rollback is another rollout |
| Canary | Send a small share of traffic to the new version, then increase | Risky changes, large audiences | Needs good metrics and traffic splitting (a router that sends a chosen share of requests to each version) |
| Blue-green | Run a full new copy beside the old, switch traffic over | Instant rollback, big releases | Double the capacity during the switch |
| Feature flags | Ship code turned off, enable it for chosen users | Separate deploy from release, gradual exposure | Flags need cleanup, and add branches |
| Shadow (dark launch) | Copy real traffic to the new version without using its answers | Testing performance and correctness safely | Adds load (up to double if all traffic is copied), and must not cause side effects |
Releasing code vs releasing a feature
- Deploying puts a new build on servers. Releasing makes users see the change.
- With feature flags, you deploy the code switched off, then release it to 1%, 10% and everyone by changing a setting, and switch it off again in seconds if it misbehaves.
- This separates the risk of a bad build from the risk of a bad feature, and it removes the need to redeploy to roll back.
How a safe rollout works
- Build once and promote. The exact artifact that passed tests goes to production.
- Deploy to a small group (a canary, or a few servers). Run health checks first (a readiness check is a request the new server must answer correctly), and do not send traffic until they pass.
- Compare metrics (errors, latency, saturation meaning how close a resource is to its limit, and business numbers such as orders per minute) between the new and old versions over enough time and traffic.
- Increase gradually if healthy: for example 5%, 25%, 50%, 100%.
- Roll back automatically if a metric crosses a threshold, by shifting traffic back or turning off the flag.
- Handle data carefully. Make database changes backward compatible (add a column, deploy code, then remove the old one later) so the old and new code can both run. Before the old column is removed, release code that no longer reads or writes it, so nothing still depends on it when it goes.
Strategy design vs the alternatives
| Concern | Canary or blue-green | Rolling | All at once |
|---|---|---|---|
| Users hit by a bad release | Few with a canary, but all of them with a plain blue-green switch | Some | All |
| Speed of rollback | Fast | Medium | Slow |
| Extra capacity needed | Some or double | Little | None |
| Complexity | High | Medium | Low |
| Needs good metrics | Yes | Helpful | No |
| Best for | Critical services | Most services | Small or internal |
Blue-green is about how fast you can undo a release, not about how many users see it. If you want both, send a small share to the new stack first, then switch.
Pick the lightest strategy that matches the cost of a failure.
Avoiding a new single point of failure
- The traffic switch (load balancer, router or mesh) is now critical. Run it redundantly and test failover.
- The deploy pipeline should be reliable and have a manual, documented path for emergencies.
- Feature flag service: cache flag values locally and use safe defaults if it is down.
- Shared data: old and new versions often share one database, so migrations are the real risk. Keep them reversible.
- Rollback has limits. If the new version already wrote data in a new format, switching traffic back does not undo that data. While a rollout is partial, old and new versions run together, so they must understand each other's messages and data. When you switch away from a server, let in-flight requests finish (connection draining) before stopping it.
You accept extra capacity, more tooling and the discipline of backward-compatible changes.
Common mistakes
- No health checks before traffic. New servers receive requests before they are ready.
- Releasing database changes that break the old version. Rollback then fails.
- Canary with too little traffic or time. Rare errors are invisible. For example (illustrative numbers), at 1,000 requests per second a 5% canary sees 50 requests per second, or 3,000 per minute. A bug that fails 1 request in 1,000 then shows up only about 3 times a minute, which is hard to tell from normal noise.
- No automatic rollback. People notice late.
- Flags that never get removed. Old branches pile up.
- Deploying on Friday evening without a plan. Keep releases small and frequent.
How to talk about deployment in an interview
- Start with the goal: no downtime and a fast way back.
- Describe a rolling or canary release with health checks and metrics, and blue-green when instant rollback matters.
- Mention feature flags to separate deploy from release, and backward-compatible database migrations.
- Name the trade-off: safer releases cost extra capacity, tooling and process.