System design · 9 of 16
Mid
Senior
- Monitoring and alerting for 100 servicesSRE · Platform · DevOps
- Secrets management platformDevOps · Platform · SRE
- Multi-region active-active serviceSRE · Platform
- Distributed job scheduler (cron at scale)SRE · Platform
- Internal developer platform (IDP)Platform
- Multi-tenant Kubernetes platformPlatform · DevOps · SRE
- GitOps for a fleet of 100 clustersPlatform · DevOps
- ML training platform and feature storeMLOps · Platform
- LLM inference platformMLOps · Platform · SRE
MID · 11 MIN · DEVOPS · SRE
Safe deployments: canary and feature flags
Shift traffic step by step, compare the canary with stable using real metrics, roll back automatically, and decouple deploy from release with flags.
- Peak load
- 1,000 req/s service
- Availability target
- change failure < 15%
- RTO: back up within
- < 30 s rollback
- RPO: data you can lose
- 0
← Swipe sideways to see the whole diagram →
The question
"Most of our incidents start with a deploy. Design a deployment system that catches bad releases before they hurt most users."
Requirements
- New versions reach a small share of users first.
- Automatic checks decide to continue or roll back, with no human watching graphs.
- Rollback in under a minute.
- Product teams can turn features on for some users without a deploy.
How it works
- The new version (canary) starts next to the stable version.
- A traffic router (ingress controller or service mesh) sends 5% of requests to the canary.
- The rollout controller (Argo Rollouts or Flagger) runs an analysis: error rate, p99 latency and SLO burn for the canary compared with stable, from Prometheus or Datadog.
- If healthy, it moves to 25%, 50%, then 100%, pausing at each step. If not, it sends all traffic back to stable automatically.
- Feature flags hide unfinished features inside the code; they can be turned on for staff, then 1% of users, and turned off instantly.
Remember it: deploy is shipping code; release is turning on the feature. Flags let you do them at different times.
Strategies compared
| Strategy | How | Good for | Cost |
|---|---|---|---|
| Rolling | replace pods a few at a time | simple apps | bad version reaches everyone gradually |
| Blue-green | run two full copies, switch all traffic | instant switch and rollback | double capacity during deploy |
| Canary | small % first, grow on good metrics | catching problems with real traffic | needs good metrics and routing |
| Feature flag | code is deployed but off | product launches, kill switches | flag cleanup work |
What breaks and how it heals
- Too little traffic to judge the canary: run analysis longer, or use synthetic tests too.
- Database changes: use expand-and-contract migrations so old and new versions both work during the rollout.
- Bad config, not code: treat config changes like code: reviewed, gradual and reversible.
Load and capacity: is 5% enough to judge?
| Item | Assumption | Result |
|---|---|---|
| Service traffic | 1,000 requests/s | the canary at 5% gets 50 requests/s |
| Analysis window | 10 minutes | 30,000 canary requests |
| Normal error rate | 0.1% | ~30 errors expected |
| Bad release | 1% errors | ~300 errors: a clear signal in 10 minutes |
| Full rollout | 5% → 25% → 50% → 100%, 10 min each | about 40 minutes |
High availability during deploys
| Target | Number | How it is met |
|---|---|---|
| Rollback time | under 30 seconds | the controller moves traffic weights back to stable; no new pods needed |
| Extra capacity during a rollout | +5-10% | canary pods run beside stable pods |
| Change failure rate | under 15% (DORA "elite" teams: lower still) | automatic analysis catches bad releases at 5% traffic |
| Data safety | no lost writes | expand-and-contract database migrations: old and new versions both work |
What interviewers listen for
- Metrics-based automatic promotion and rollback.
- Backward-compatible database changes.
- Separating deploy from release with feature flags.