Skip to main content
07

Rolling vs blue-green vs canary

MediumDeploymentsCanaryBlue-green

Compare rolling, blue-green and canary deployments. When do you use each?

TL;DR

Rolling: replace instances with the new version a few at a time. It needs no extra capacity and is the Kubernetes default, but old and new versions run side by side, and rollback is another rollout. Blue-green: run a full second environment with the new version, test it, then switch all traffic at once. Instant rollback (switch back), but double the capacity during the deploy. Canary: send a small percentage of real traffic (say 1%, then 10%, then 50%) to the new version, watch error rates and latency, and continue or roll back automatically. It's the safest for risky changes, but needs good metrics and traffic-splitting tooling.

Key points

RollingBlue-greenCanary
Extra capacityLittle (maxSurge)2× during the switchSmall
Rollback speedMinutesSecondsSeconds
Blast radiusGrows as it rollsAll users at the switchSmall % of users
NeedsReadiness probesLoad balancer or DNS switchMetrics plus traffic splitting
  • All three require backward-compatible changes, since two versions coexist (or you need to be able to switch back).
  • Database migrations: use expand and contract. Add new columns or tables first, deploy code that works with both, then remove old ones in a later release.
  • Feature flags decouple deploy from release: ship the code dark, then enable it per user or percentage.
  • Tooling: Kubernetes Deployment (rolling), Argo Rollouts or Flagger (canary and blue-green with automated analysis), and load balancer weighted target groups.

Example

yaml
# Kubernetes rolling update
strategy:
  type: RollingUpdate
  rollingUpdate:
    maxSurge: 25%
    maxUnavailable: 0 # never drop below desired capacity

Common follow-ups

  • What's a shadow (dark) deployment? Mirror production traffic to the new version without returning its responses to users. Good for testing performance safely.
  • How does an automated canary decide? It compares the canary's error rate and latency to the baseline over a time window and aborts past a threshold.

What interviewers look for

Tip

Compare cost, rollback speed and blast radius, and mention backward-compatible database migrations.

  • Red flag: ignoring the database, the hardest part of zero-downtime deploys.

Was this helpful?