Deployment Strategies

Rolling, blue-green, canary and feature flags — release without downtime and roll back fast.

Intermediate8 min read3 interview questions

How you replace the running version matters as much as what you deploy. The right strategy limits how many users see a bad release and how quickly you can undo it.

All of them rely on good health checks and metrics: you can only roll back automatically if you can detect that something is wrong.

Diagram

95%5%Load balancertraffic splitBlue — v1current, 95% trafficGreen — v2canary, 5% trafficMetricserrors, latency
A canary sends a small share of traffic to the new version and widens it while metrics stay healthy.

Key concepts

Recreate
Stop v1, start v2. Simple, with downtime. Fine for internal tools.
Rolling update
Replace instances a few at a time. No downtime; v1 and v2 run together briefly. Kubernetes’ default.
Blue-green
Run v2 beside v1, then switch all traffic at once. Instant rollback by switching back; needs double capacity.
Canary
Send a small percentage of traffic to v2, watch metrics, then increase. Limits blast radius.
Feature flags
Deploy code turned off and enable it per user or tenant. Separates deployment from release.
A/B testing
Route users to variants to measure business impact, not just stability.

Trade-offs

Benefits

  • Zero-downtime releases
  • Fast rollback
  • Problems affect a small group of users first

Costs

  • Two versions run at once, so APIs and databases must be backward compatible
  • Blue-green doubles infrastructure during the switch
  • Feature flags need cleanup

Use it when

  • Rolling for most stateless services
  • Blue-green when instant cutover and rollback matter
  • Canary for high-traffic or high-risk changes
  • Feature flags for large features built over several releases

Common mistakes

  • Database migrations that break the old version during a rolling deploy — use expand/contract
  • Canaries without automated comparison of error rates
  • Hundreds of stale feature flags

Interview questions

Q1How do you change a database column during a zero-downtime deploy?
Expand and contract: add the new column, deploy code that writes both and reads new, backfill, deploy code that uses only the new column, then drop the old one in a later release.
Q2Blue-green or canary?
Blue-green gives an instant, all-or-nothing switch and rollback. Canary exposes a fraction of users first and suits large traffic where metrics can reveal problems early.
Q3Why separate deployment from release?
With feature flags you can ship code to production continuously while choosing when, and for whom, a feature becomes visible.