Overview
Curated: · Written: · Reviewed:
Deployment Strategies (Blue-Green, Canary, Rolling)
In one line
Strategies that control how a verified release reaches production, trading delivery speed and infrastructure cost against blast radius and rollback speed. Use rolling for stateless services with tight capacity, blue-green when cutover and rollback must be instant and auditable and you can pay for double capacity, and canary when you need evidence from live traffic before full exposure.
Key definitions
- Blast radius: the share of users or requests exposed to a bad release before it is detected or reverted.
- maxSurge: extra pods allowed above the desired replica count during a rollout. Percentages round up.
- maxUnavailable: pods allowed below the desired count during a rollout. Percentages round down.
- Expand-contract: a three-step schema change (expand, migrate, contract) so old and new code can run against the same data.
- Canary cohort: the population routed to the new version, chosen by stable sampling, tenant or region.
- Guardrail: a predeclared metric, threshold and minimum sample size that gates each promotion step.
Formulas and complexity
So 6 replicas at 25%/25% allow at most 8 pods and require at least 5 ready.
Both fleets at 8 instances with a 280-connection budget: 17 per instance (17.5 rounded down). Labelled worked example. Double capacity: blue-green and full canary each need about capacity during the window; rolling needs only the surge.
How it works
- Rolling: new pods start within the surge allowance, and old pods are removed only as replacements report Ready. Old and new versions serve together for the whole rollout.
- Blue-green: green is built and validated while blue serves. The load balancer pointer flips, and blue stays warm so rollback is another flip.
- Canary: traffic weight moves through steps (1%, 5%, 25%, 100%) with a dwell time per step. Each step compares the canary to a concurrent baseline. Abort reverts the weight.
When to use and when not to
| Factor | Rolling | Blue-green | Canary |
|---|---|---|---|
| Extra capacity | Surge only | About 2x during window | About 2x at full canary |
| Rollback | Reverse roll, proportional to rollout time | Pointer flip, seconds | Weight revert, fast |
| Mixed versions | Whole rollout | Brief at cutover, old fleet kept warm | Whole canary window, by design |
| Choose when | Stateless, tight capacity, small blast radius | Auditable instant cutover, double capacity affordable | High traffic, fast metrics, evidence before exposure |
| Avoid when | Instant rollback needed, no compatibility guarantee | Cannot double capacity, singleton background work | Low traffic cannot reach sample size, metrics lag hours |
Traps interviewers probe
- Assuming zero-surge rollouts keep capacity. With maxSurge 0 the controller removes pods before replacements exist, so survivors absorb the load and latency climbs with no NotReady pods and no errors. Fix: allow surge, or cap maxUnavailable so the remaining pods stay under their saturation point at peak.
- Believing a PodDisruptionBudget governs a rolling update. A PDB limits voluntary evictions. Rollout limits come from maxSurge and maxUnavailable. With 10 replicas and maxUnavailable 2, Ready pods can drop to 8 even with minAvailable 9. Fix: set the rollout parameters to the floor you need.
- Bundling a destructive migration with the release. Old code still reads the dropped column, so the traffic rollback routes it into an incompatible schema. Fix: expand-contract, with the contract step as a separate, gated deployment.
- Promoting on a global average. A healthy aggregate can hide one tenant, region or endpoint burning. Fix: check per-cohort slices against the baseline, and treat too few samples as a failed measurement, not a pass.
- Trusting the configured weight. Retries, async workers and batch jobs shift the real exposure. Check: 10% of requests at 48 ms against 90% at 12 ms gives 4.8 / (4.8 + 10.8), about 31% of handler CPU. Fix: verify achieved share per version from request counts and CPU.
Interview tips
Open by naming the strategy, stating the four axes (speed, blast radius, cost, rollback speed), then the hard constraint: schema compatibility and how abort works. Do not pick a favorite without the workload's properties.
Follow-ups to expect:
- Canary or blue-green? Answer with detection speed, double-infra cost and state compatibility.
- How do you roll back a canary that already wrote new-format data? Weight revert plus reconciliation, because expand-contract keeps old readers working.
- Minimum cohort and dwell time? Give figures from metric latency and sample-size math, labelled as hypothetical if needed.
- What breaks that is not the new code? Capacity during surge, connection draining, background jobs, caches, external callbacks.
30-second outline: I would use [strategy] because [workload property]. Expose 1%, then 5%, 25%, 100%, gating each step on error and latency against a concurrent baseline with a minimum sample size. The schema is expand-contract so both versions run. Abort is a weight revert, a write pause and reconciliation. I would verify the achieved weight and check background jobs and caches during the rollout.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.