SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
  • Deployment Strategies Overview
  • CI/CD Pipelines
  • Rolling Deployments
  • Blue-Green Deployments
  • Canary Releases
  • Feature Flags
  • A/B Testing Infrastructure
  • Schema Migrations
  • Rollbacks and Immutable Infrastructure
  • Multi-Region and Active-Active
  • Infrastructure as Code (Terraform)
  • Auto-Scaling Policies
  • Zero-Downtime Deployment
  • Chaos Engineering
  • Shadow Traffic and Dark Launches
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Operations and Security/Deployment Patterns

Canary Releases

Send the new version to a small slice of users first, and grow it only if it looks healthy.

⏱ 13 min readIntermediateMust KnowInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

A canary release sends the new version to a small share of real users first (say 1%). You compare it with the old version. If it looks healthy, you give it more traffic. If not, you pull it back.

  • The name comes from the canary in the coal mine: a small early warning before the danger reaches everyone.
  • A bad release hurts only a few users and is stopped early.
  • It needs good metrics and a way to split traffic.

02Concept: What is it?

Tests cannot find every bug. Some only show with real users, real data and real load. A canary release accepts this and limits the damage: the new version runs next to the old one, and only a small part of the traffic goes to it.

A canary release has three parts. First, a traffic split (1%, then 5%, 25%, 50%, 100%). Second, analysis: compare the canary with the old version on error rate, latency and business numbers (for example, orders per minute). Third, a decision: promote to the next step, hold, or roll back. Many teams automate this decision.

A growing slice of traffic
1️⃣1%check
→↓healthy
5️⃣5%check
→↓healthy
🔢25%check
→↓healthy
🔢50%check
→↓healthy
✅100%done
Each step is only taken if the canary stays healthy compared with the old version.
🧠Compare, do not guess
Look at the canary against the old version at the same time, not against yesterday. A busy hour can raise errors for both versions. The difference between the two is what tells you about the new code.

03Real-Life Example

🍵Tasting the Soup Before Serving the Wedding
A chef has changed the recipe for a soup that will be served to 500 guests. Instead of filling every bowl, the chef sends the new soup to two tables only and watches. If those guests smile and finish the bowl, the chef sends it to ten tables, then to the whole room. If anyone gets sick, only two tables are affected, and the old soup is still in the pot for everyone else.
The wedding
Canary release
Two tables get the new soup
A small share of users gets the new version
The rest still get the old soup
Most traffic stays on the stable version
The chef watches the faces
Metrics: errors, latency, business numbers
Ten tables, then the whole room
Growing steps: 1%, 5%, 25%, 100%
Someone gets sick, stop
A rollback rule that sends all traffic back
Only two tables affected
A small blast radius
Guests should be picked fairly
Traffic split by user, region or random sample
What a bad release costs: all at once vs canary
All at once
Users who hit the bugeveryone, until you roll back
Canary at 1 to 5%
Users who hit the bugonly the early slice
The same bug. The canary stops it while few users are affected (illustrative sizes).

04Why Do We Need It?

🎯Small blast radius
A bug only reaches the users in the canary slice, not the whole customer base.
🌍Test with real traffic
Real users, real data and real load find problems that staging never does.
📊Decisions from data
Promote or roll back based on numbers, not on a feeling.
⚡Fast feedback
You learn within minutes whether the release is healthy.
🤖Can be automated
A tool can compare metrics and promote or abort without a person watching.
😌Less fear of shipping
When mistakes are cheap, teams release smaller changes more often.
Do not bet everything on one release. Show it to a few users, watch the numbers, and let the data decide the next step.

05Where Do We Use It?

🌐Large web services
Sites with millions of users where one bad release is very expensive.
📱Mobile app rollouts
App stores let you release to a percentage of users (staged rollout).
☸️Kubernetes
Tools such as Argo Rollouts, Flagger and service meshes shift traffic in steps and check metrics.
🔀Load balancers and gateways
Weighted routing sends, for example, 5% of requests to the new target group.
🚩Feature flags
A flag can expose a new feature to a percentage of users inside one running version.
🗄️Risky back-end changes
A new database engine, cache or algorithm can be tried on a slice of traffic first.

06Types / Parts / How It Works

How to choose the canary slice

MethodHow it worksGood and bad
Percentage of requestsA weight at the load balancer sends 5% of requests to the canarySimple. The same user can bounce between versions.
Sticky by userA stable hash of the user id decides who is in the canaryEach user sees one version. Needs a user id (or cookie).
By region or data centreRelease to one small region firstGood for catching regional problems. The slice may not be typical.
Internal users firstEmployees get the new version before customers (dogfooding)Very safe, but staff do not behave like real users.
By customer typeFree users or low-risk accounts firstProtects the biggest customers. Slice may differ from the rest.

What to compare

Canary against baseline
Baseline (old version)
🖥️v195% of traffic
📊Errors, latency, orders
Canary (new version)
🖥️v25% of traffic
📊Errors, latency, orders
Stable Being tested
Both run at the same time and get a similar mix of traffic.
SignalWhy it matters
Error rate (5xx, exceptions)The clearest sign of a bug
Latency (p95, p99)A new version may work but be slow
Resource use (CPU, memory)Leaks and heavy code show here first
Business metrics (orders, sign-ups)A release can be technically healthy but break the checkout flow
Logs and tracesExplain why something changed
VisualizerRoll out in stages and let the metrics decidePick how the new version behaves, set how strict the checks are, and press Promote. Watch the check fail on a buggy or slow version, and how few requests were hurt.
How does the new version really behave?

The new version has a bug that fails about 4% of requests (illustrative). The old version has about 0.5% errors and 120 ms p95 latency (illustrative).

Traffic split (each square is 2% of users, cyan = old version, fuchsia = canary)
Stages (the canary is checked against the old version at each one)
1%
failed
5%
waiting
25%
waiting
50%
waiting
100%
waiting
Error rate
Old: 0.5%Canary: 4.6%
limit 1.5%
p95 latency
Old: 120 msCanary: 121 ms
limit 150 ms
Canary share
1%
of all traffic
Error rate (canary)
4.6%
old: 0.5%
Latency (canary)
121 ms
old: 120 ms
Requests on bad version
20
vs 2000 if all at once
The check fails at 1%: errors are 4.1 points above the old version (limit 1). Press Roll back. The automatic decision is to stop and send all traffic to the old version.

A simplified model. The error rates, latencies and request counts are illustrative, with fixed small changes at each stage so every run is the same. Real canaries compare the canary and the old version at the same time, with enough traffic to be sure the difference is not just noise.

07How to Use It / Steps / Implementation

Running a canary release

  1. 1
    Pick the signals and limits
    Decide before you start: for example, errors may rise at most 1 point and p95 latency at most 20% compared with the old version.
  2. 2
    Deploy the canary next to the old version
    Start a few instances of the new version. Keep the old ones running and unchanged.
  3. 3
    Send a small share of traffic
    Use a weight or a stable user hash. Start at 1% or 5%, depending on your traffic.
  4. 4
    Wait for enough data
    A tiny slice needs time to collect enough requests. Short, noisy checks give wrong answers.
  5. 5
    Compare with the old version
    Check the canary and the baseline at the same time, on the same signals.
  6. 6
    Promote, hold or roll back
    If it passes, move to the next step. If it is unclear, wait longer. If it fails, send all traffic back.
  7. 7
    Finish and clean up
    At 100%, retire the old version after a safe period. Write down what you learned.
💡Make bad canaries stop themselves
Set automatic rules so that a failed check rolls the release back without waiting for a person. A rollback at 3 a.m. should not depend on someone waking up.
⚠️A very small slice may hide a rare bug
A bug that affects 1 in 10,000 requests will not show up in a few hundred. Choose the slice size and the waiting time so that you get enough requests to see the problem you care about.

08Key Terms to Know

TermMeaning in easy words
CanaryThe new version that serves only a small share of users at first
BaselineThe current stable version that the canary is compared with
Traffic split / weightThe share of requests sent to each version
Blast radiusHow many users a bad change can affect
PromotionMoving the canary to a larger share of traffic
RollbackSending all traffic back to the old version
Canary analysisComparing the canary and baseline signals to decide
SLO / thresholdA limit that decides pass or fail (for example, errors above 1%)
Progressive deliveryReleasing in steps, with checks between them
Sticky routingThe same user is always sent to the same version
DogfoodingUsing the new version inside the company first

09Pros, Cons and Trade-offs

✅ Pros
  • A bad release harms only a few users
  • Tests with real traffic and real data
  • Decisions come from metrics
  • Can be automated end to end
  • No second full environment is needed
⚠️ Cons
  • Needs good monitoring to work at all
  • Two versions run at once, so data and APIs must be compatible
  • A small slice can miss rare bugs
  • Slower than a single switch
  • More tooling: traffic splitting and analysis

Trade-offs

ChoiceWe gainWe lose
Smaller first sliceA smaller blast radiusLess data, so a longer wait for a clear answer
Larger first sliceFaster, clearer signalsMore users hit a bug
More stagesMore chances to catch a problemA longer release
Automatic promotionFast and no human neededA bad rule can promote a bad version
Manual approvalA person decidesSlow, and easy to forget
Canary instead of blue-greenGradual exposure and lower costRollback and monitoring need more care

10Common Problems and Mistakes

Common mistakes

  1. No clear pass or fail rule. People argue over graphs while users suffer.
  2. Too little traffic. A few requests cannot prove anything. The canary "passes" by accident.
  3. Comparing with the wrong baseline. Comparing with last week instead of the old version at the same time mixes in daily patterns.
  4. Watching only technical numbers. The release works but sales fall, and nobody checks.
  5. Incompatible data changes. Version 2 writes data that version 1 cannot read, so a rollback breaks things.
  6. Users bounce between versions. The page looks different on every click when the split is not sticky.
  7. Skipping the rollback test. The first rollback happens in an emergency and fails.

Things to watch

📉Noise
Small differences between two small samples are often just luck. Use enough requests, or a statistical check.
🗄️Shared state
Both versions use the same database and cache, so changes must work for both.
⏱️Slow-burn bugs
Memory leaks and rare errors may need hours to appear. Hold at a stage long enough.
🧩Hidden coupling
Other services may call the canary and its answer may break them later.

11Real-World Examples

🧰Argo Rollouts and Flagger
Kubernetes tools that shift traffic in steps and check metrics before each step.
☁️Cloud load balancers
Weighted target groups and traffic splitting support canary style releases on major clouds.
📱Mobile app stores
Staged rollouts release an update to a percentage of users and let you halt it.
🕸️Service meshes
Meshes such as Istio and Linkerd can route a set percentage of requests to a new version.
🌐Large internet companies
Many large companies release in rings: employees, then a small region, then everyone.
🤖Automated canary analysis
Some platforms compare canary and baseline metrics automatically and decide.
📝Note
Tool names and features change. Check the current documentation for how your tool splits traffic and checks health.
Mini case: the canary catches a slow query
🚀Release v21% of traffic
→↓
📊Comparep95 +80% vs old
→↓over limit
↩️Auto rollback100% on v1
→↓
🔧Fix the querythen try again
Illustrative numbers.

12Related Topics to Read Next

Deployment Strategies Overview→

See where canary fits among the other release methods.

Blue-Green Deployments→

A fast all-at-once switch, with no gradual exposure.

Rolling Deployments→

Another gradual release, but by servers, not by user share.

Feature Flags→

Turn a feature on for a percentage of users without a new deployment.

Alerts and Monitoring→

A canary is only as good as the signals you watch.

A/B Testing Infrastructure→

Split users the same way, but to measure which version wins.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • ✔What: send the new version to a small share of users, then grow the share if it is healthy.
  • ✔Steps: for example 1%, 5%, 25%, 50%, 100%, with a check between each one.
  • ✔Compare: canary against the old version at the same time: errors, latency, business numbers.
  • ✔Rollback: if a limit is crossed, send all traffic back. Automate it.
  • ✔Benefit: a small blast radius, tested with real traffic.
  • ✔Risks: too little data, noisy numbers, incompatible data, users hopping between versions.
  • ✔Tools: weighted load balancing, service meshes, Argo Rollouts, Flagger, staged app-store rollouts.
  • ✔One line: “Taste the soup at two tables before you serve the whole room.”
← Previous
Blue-Green Deployments
Next →
Feature Flags