Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Courses/Reliability and Failure
Lesson 21 of 24

Safe deploys: canaries, blue/green and feature flags

Most outages start with a change; release changes so that bad ones are caught small and rolled back fast.

15 min read

Change is the main risk

Hardware fails at a fairly steady rate, but most serious incidents are triggered by something a team changed: new code, a config flag, a schema migration, a dependency upgrade. The goal of deploy safety is not to avoid change but to limit its blast radius and shorten the time a bad change stays live. Small, frequent deploys help: a diff of 50 lines is easy to roll back and easy to reason about; a quarterly release of 5 000 is neither.

Canary releases

A canary sends a small slice of traffic to the new version first, while the rest stays on the old one. Compare error rate, latency and business metrics between the two groups, then widen in stages if they match.

  • Typical stages: 1%, then 10%, 50%, 100%, with a bake time of 10 to 60 minutes each
  • Automate the comparison and roll back automatically on regression
  • Deploy one zone or region at a time so a bad build never reaches everywhere at once
  • Treat config changes exactly like code: staged, reviewed and reversible

Blue/green and feature flags

Blue/green runs two full environments. You deploy to the idle one, test it, then switch traffic at the load balancer; rollback is switching back, which takes seconds. It costs double capacity during the switch. Feature flags separate deploying code from releasing behaviour: new code ships dark, then the flag enables it for staff, then 5% of users, and a kill switch turns it off instantly without a deploy. Remove flags once a feature is fully launched, or they become their own source of bugs.

Database changes need care

Rollback is easy for stateless code and hard for data. Use expand and contract migrations: first add the new column or table while old code keeps working, deploy code that writes both and reads the new one, backfill, and only drop the old structure once nothing uses it. Every step stays compatible with the version before and after it, so any single deploy can be rolled back safely.

Key takeaways

  • Most incidents are triggered by changes; small and frequent deploys limit the damage
  • Canary in stages with automated metric comparison and automatic rollback
  • Blue/green gives instant rollback; feature flags give instant kill switches
  • Expand and contract migrations keep every deploy reversible

Sign in to track lessons and earn badges.

Multi-AZ versus multi-regionChaos engineering and game days

Challenge checkpoint

Course: 0/24 lessons · 0/10 challenges0%

Build it on the canvas, pass the review (70+) and mark it complete to count it toward the course badge.

  1. 9/10Design Live Video StreamingKeep millions of viewers watching through ingest failures, zone loss and launch spikes using redundancy, CDNs and staged rollouts.MAJORHardPRO
All 10 challenges →