Miners once carried canaries underground because the birds reacted to toxic gas before people did. A canary release uses a small group of real users the same way. A new version goes to, say, 5% of traffic. If that group sees more errors or slower responses than everyone else, you stop and roll back. Only 5% of users were affected, for a few minutes.
How it works
- Deploy the new version next to the stable one, with a small amount of capacity.
- Route a slice of traffic to it: a percentage of requests, a set of internal users, one region or one tenant.
- Compare the canary with the stable version on the same metrics: error rate, p95 latency, saturation and a business signal such as checkout success. Good observability is a precondition.
- Promote in steps (for example 5%, 25%, 50%, 100%) if the numbers hold, or abort and send all traffic back to stable.
Automated canary analysis does step 3 with a query and a threshold, so nobody has to watch dashboards at every step. A natural threshold is the service's SLO: abort if the canary burns error budget faster than the stable version.
Example: a canary with Argo Rollouts on Kubernetes
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: 10m}
- setWeight: 50
- pause: {duration: 10m}
When a new image tag is applied, Argo Rollouts sends 5% of traffic to it and waits ten minutes, then moves to 25% and 50%, then to everyone. With an ingress controller or service mesh it splits requests exactly. Without one, it approximates the weight by pod count, so 5% of 10 pods becomes one pod. Attach an analysis template that queries Prometheus for the 5xx rate, and the rollout aborts by itself if the canary's error rate crosses the limit.
Mobile apps can't route traffic, but stores offer the same idea. Apple's phased release for automatic updates goes to 1%, 2%, 5%, 10%, 20%, 50% and then 100% of users over seven days, and you can pause it. Google Play offers staged rollouts by percentage.
Canary vs blue-green, rolling and A/B testing
- Blue-green switches all traffic at once after testing the new environment. Canary exposes real users gradually.
- Rolling replaces instances in batches but doesn't compare versions or stop automatically on bad metrics.
- A/B testing splits users to measure which variant performs better for the business. A canary asks only whether the new version is safe. A/B tests usually run on feature flags and last days or weeks. Canaries last minutes or hours.
When canaries don't work well
- Low traffic. At 5% of 200 requests an hour, the canary sees too few requests to judge. Use longer steps or target internal users first.
- Breaking database changes. Both versions share the data, so schema changes must be backward compatible.
- Sticky effects. If the canary sends emails or writes bad data, rolling back the code doesn't undo them.
Common mistakes
- Judging only on errors and missing a latency regression.
- Letting the same user flip between versions on each request. Route by user or session.
- Comparing the canary with last week instead of with the stable version running right now.
We design release pipelines with automated canary analysis through our cloud and infrastructure and quality engineering work.