A canary deployment releases a new version to a small share of real users first, often 1% to 5%, while everyone else stays on the current version. If error rates and latency stay healthy, traffic to the new version increases in steps until it reaches 100%. If they don’t, traffic goes back to the old version and only a few users were affected.
The name comes from coal mining. Miners carried canaries underground because the birds reacted to toxic gas before people did. A sick canary was the warning to get out. A canary deployment works the same way: a small group of users hits the new version first, and if something is wrong, you find out from them before everyone else does.
It is one of the most popular deployment strategies for high-traffic services, and for good reason. This guide covers how a canary rollout works, how to run one in Kubernetes, how it differs from canary testing and blue-green, and how to test before the canary gets its first request.
What is a canary deployment?
A canary deployment is a progressive release where the new version runs next to the old one and receives a controlled percentage of production traffic. The percentage grows only while the new version proves healthy. It is also called a canary release or canary rollout.
The important word there is controlled. In a rolling deployment, the share of users on the new version grows too, but it grows as fast as pods get replaced, and nothing stops it unless a health check fails. In a canary, the traffic split is a deliberate setting, and each step waits for evidence before moving on.
That makes canary the closest thing to a safety net you get with real users. A bad release still reaches someone. It just reaches 1% of your traffic for ten minutes instead of 100% of it until someone notices.
How a canary rollout works
A canary rollout has three moving parts: a traffic split that sends a small share of requests to the new version, metrics that compare the canary against the stable version, and a rule that either promotes the canary to the next step or rolls it back.

Here is a common step plan for a service with steady traffic:
| Step | Traffic to canary | Wait | What you check |
|---|---|---|---|
| 1 | 1% | 10 min | 5xx rate, p99 latency, crash loops |
| 2 | 5% | 15 min | Same, plus key business metrics |
| 3 | 25% | 20 min | Same, plus resource usage |
| 4 | 50% | 20 min | Same |
| 5 | 100% | Old version scaled down |
The metrics matter more than the percentages. A good canary compares the canary pods against the stable pods during the same window, not against last week’s numbers. If stable has a 0.2% error rate and the canary has 0.9%, that is a signal, even if 0.9% is under your general alert threshold.
Some practical things that trip teams up:
- Too little traffic. If 1% of your traffic is three requests a minute, ten minutes gives you thirty data points. That is not enough to see a 0.5% error rate change. Either hold each step longer or start at a higher percentage.
- Sticky sessions. If a user bounces between old and new on every request, you get weird bugs that neither version has on its own. Pin users to one version with a header or cookie.
- Metrics nobody looks at. Automate the promote or rollback decision. If a human has to watch a dashboard for an hour, eventually they won’t.
- Rollback that only moves traffic. Setting the canary weight to zero stops new requests, but anything the canary already wrote to a database or queue stays there.
Canary deployment in Kubernetes
Kubernetes has no built-in canary strategy, so teams use a controller like Argo Rollouts or Flagger, or weighted routing in a service mesh such as Istio or Linkerd. Argo Rollouts replaces the Deployment with a Rollout resource that defines canary steps. Flagger works alongside your existing Deployment and automates promotion from metrics.
The quick and rough way is two Deployments behind one Service, say 19 stable pods and 1 canary pod, which gives you roughly a 5% split. It works, but the split depends on pod count, which is clumsy, and there is no automatic rollback.
Argo Rollouts makes the steps explicit:
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: payments-api
spec:
replicas: 10
strategy:
canary:
steps:
- setWeight: 5
- pause: {duration: 10m}
- setWeight: 25
- pause: {duration: 15m}
- setWeight: 50
- pause: {duration: 15m}
analysis:
templates:
- templateName: error-rate-check
selector:
matchLabels:
app: payments-api
template:
metadata:
labels:
app: payments-api
spec:
containers:
- name: payments-api
image: registry.example.com/payments-api:3.2.0
The analysis block points to a template that queries Prometheus (or Datadog, New Relic and others). If the error rate crosses the threshold, Argo aborts and sends all traffic back to stable. Pair it with a mesh or ingress controller for exact percentages instead of pod-count approximations.
Flagger takes a different route. You keep your normal Deployment, add a Canary resource, and Flagger creates the primary and canary copies, shifts weights through your mesh or ingress, and promotes or rolls back based on metric checks. Teams already on Flux tend to like it.
Canary deployment vs canary testing
Canary deployment is the release process: shifting real production traffic to a new version in steps. Canary testing is the practice of watching and validating that small group of users to decide whether the release is safe. One is how you ship, the other is how you judge what you shipped.
In practice people use the two terms loosely, and that’s fine. If you want the testing side in depth (what to measure, how to pick canary users, how to automate the verdict), we cover it in canary testing: a comprehensive guide for developers.
Canary vs blue-green deployment
Canary shifts traffic gradually and limits how many users see a bad release. Blue-green switches all traffic at once and rolls back faster. Canary needs good metrics and enough traffic to judge each step. Blue-green needs a full second environment.
| Canary | Blue-green | |
|---|---|---|
| Traffic shift | Gradual (1% up to 100%) | All at once |
| Users exposed to a bad release | Small slice | Everyone, until rollback |
| Rollback | Set canary weight to 0 | Switch router back |
| Extra cost | A few extra pods | A full second environment |
| Needs | Good observability, steady traffic | Duplicate infrastructure |
The full picture of the other side is in our post on blue-green deployment.
Testing before the canary gets traffic
A canary should only catch problems that need real load to show up. Functional regressions, like a changed response field or a broken edge case, should be caught before the canary receives its first request, by replaying recorded production traffic against the new version in CI or a pre-production step.
Here’s the thing about canaries that often gets glossed over: the 1% of users in the canary are real people. If the new version returns a wrong price or drops a field a mobile app depends on, those users get the bug. Canary limits the damage. It doesn’t remove it.
Most of what breaks in a canary isn’t a load problem. It’s a contract problem. A JSON field got renamed. A null that used to be an empty string. A default value changed. None of that needs production traffic to detect. It needs realistic requests and a comparison against what the old version did.
That is the gap Keploy fills before the rollout starts. Keploy records real API calls to your service, together with the responses from its database and downstream services, and turns them into tests with mocks. In your pipeline, you replay those recordings against the new image. Any response that differs from the recorded one shows up as a failed test with the exact field that changed. No user involved, and no production data touched, because dependencies come from the recorded mocks.

A clean sequence looks like this:
- Build the new image.
- Replay recorded production traffic against it with Keploy. Fail the pipeline on unexpected differences.
- Start the canary at 1% to 5% and let metrics judge behavior under real load.
- Promote step by step, or roll back automatically.
If the release is a big rewrite and you want to see it under full live load before any user hits it, run a shadow deployment first, then the canary. You can see the record and replay flow on Keploy’s API testing page.
FAQs
Why is it called a canary deployment?
The name comes from the canaries coal miners once carried underground. The birds reacted to toxic gas before the miners did, so a struggling canary was an early warning. In a canary deployment, a small group of users gets the new version first and acts as that early warning before the release reaches everyone.
How much traffic should a canary get?
Most teams start between 1% and 5% and increase in steps such as 5%, 25%, 50% and 100%. The right starting point depends on your volume. The canary needs enough requests in each step to show a real difference in error rate or latency, so low-traffic services often start higher or hold each step longer.
What is the difference between canary deployment and A/B testing?
A canary deployment checks whether a new version is safe to release, using technical metrics like errors and latency, and it ends with everyone on the new version. A/B testing checks which version performs better for the business, using metrics like conversions, and it can keep both versions running for weeks. Canary picks users at random, while A/B testing usually splits them by segment.

Leave a Reply