Canary Deployment and Canary Release: How the Strategy Works
A canary deployment routes a small percentage of live traffic to a new version while everyone else stays on the current one, then widens that share only if error rate and latency hold against the stable version. It differs from blue green, which switches all traffic at once and needs two full environments, and from a rolling deployment, which replaces instances without pausing to judge the result. The hard parts are database changes, since both versions share one schema, and having an automatic abort rule rather than a human watching a dashboard.
Skip the manual setup. DeployManage provisions your server and ships zero-downtime deploys on any cloud.
$ get started freeWhat is a canary deployment?
A canary deployment is a release strategy that sends a small slice of live traffic to the new version of your application while everyone else stays on the current one. You watch the errors and latency for that slice, and only widen it if the numbers hold. If they do not, you route the slice back and almost nobody noticed.
It is one of five common approaches, compared side by side in our guide to deployment strategies. The name comes from the canary carried into coal mines as an early warning. The point is the same: expose something small and observable to the danger first, so the blast radius of a bad release is a few percent of users instead of all of them.
How does a canary deployment work?
Both versions run at the same time behind whatever splits your traffic, usually a load balancer or reverse proxy. You move the dial in stages and check the metrics between each one.
| Stage | Traffic on the new version | What you are looking for |
|---|---|---|
| Bake | 0 percent, health checks only | The process starts, passes health checks and connects to its dependencies |
| First slice | 1 to 5 percent | New error classes, 5xx rate, latency at the 95th and 99th percentile |
| Widen | 25 percent | The same signals under real concurrency, plus queue and database load |
| Majority | 50 to 75 percent | Resource saturation, connection pool limits, cache hit rates |
| Complete | 100 percent | Steady state, then retire the old version |
The stages matter less than the rule between them: every step needs a defined metric, a threshold and an automatic way back. A canary with no automated rollback is just a slower deployment with extra steps.
Canary deployment vs blue green deployment
Both keep two versions alive, but they differ in how traffic moves and what it costs.
| Canary | Blue green | |
|---|---|---|
| Traffic shift | Gradual, in percentage steps | All at once, when you flip the router |
| Infrastructure needed | Enough for the current version plus a small slice | Two full production environments |
| Users exposed to a bad release | Only the current slice | Everyone, until you flip back |
| Rollback speed | Fast, drop the slice to zero | Very fast, flip the router back |
| Best for | Changes whose risk only shows under real traffic | Big releases you want on or off cleanly |
Blue green is the cleaner switch and the more expensive one, because you pay for a duplicate environment. Canary is cheaper and more informative, because real users generate signals a staging environment never will. Our longer comparison of blue green and rolling deployments covers where each one fits.
Canary deployment vs rolling deployment
A rolling deployment replaces instances in batches until every one runs the new version. It is a delivery mechanism, not a decision mechanism: the rollout continues unless something fails outright. A canary adds a deliberate pause and a judgement call, where you look at real metrics and decide whether to continue.
The practical difference is what happens with a bug that does not crash anything. A memory leak, a slow query or a subtly wrong calculation will roll all the way out unnoticed, but a canary with a latency threshold catches it while only a few percent of users are affected.
Canary deployment vs A/B testing
They look identical from the outside and answer completely different questions. A canary asks whether the new version is broken, runs for minutes or hours, and is judged on error rate and latency. An A/B test asks whether a change is better, runs long enough to reach statistical significance, and is judged on conversion or engagement.
Using one as the other is a common mistake. A canary that runs for two weeks is an expensive way to maintain two code paths, and an A/B test cut short after twenty minutes has not measured anything. Error rate and latency tell you the canary is not broken, but they say nothing about whether the change actually helped, which is where product analytics that unify usage, feedback and revenue signals do the work instead.
What metrics should you watch during a canary?
Compare the canary against the stable version over the same window, not against yesterday. Traffic patterns move, and an absolute threshold will page you at every lunchtime peak.
| Signal | Why it matters | Typical abort rule |
|---|---|---|
| HTTP 5xx rate | The clearest evidence something is broken | Canary rate exceeds stable by any meaningful margin |
| Latency at p95 and p99 | Catches slow queries and N+1 problems that averages hide | Sustained regression against stable over several minutes |
| Application error log volume | Surfaces exceptions that still return a 200 | New exception classes appearing only on the canary |
| Queue depth and job failures | Background work fails quietly while the site looks fine | Depth climbing without a matching traffic increase |
| Database load | A new query pattern can hurt the old version too | Connection or CPU saturation on the shared database |
Averages are the trap here. A change that breaks one endpoint badly can leave the mean response time almost unchanged, which is why percentiles belong in the abort rule and averages do not.
How long should a canary run?
Long enough to see the traffic that matters, which is a property of your application rather than a fixed number. If a bug only appears when the hourly cron fires, a ten minute canary will miss it. A useful floor is one full cycle of your slowest scheduled work, and a useful ceiling is the point where maintaining two versions costs more than the risk it removes.
For most web applications that lands somewhere between fifteen minutes and a few hours per stage. Anything measured in days is usually a sign the team does not trust its metrics, and the fix is better instrumentation rather than a longer wait.
How do you handle database changes during a canary?
This is the part that breaks real canary rollouts, because both versions share one database. The old code and the new code have to work against the same schema for the entire rollout, which rules out any migration that removes or renames something in a single step.
The standard approach is expand and contract. Add the new column, deploy code that writes to both and reads the old one, backfill, switch reads to the new column, and only drop the old one in a later release once no running version references it. We cover the mechanics in detail in zero downtime database migrations.
The rollback consequence is easy to miss. Your code can go back to the previous version in seconds, but a dropped column cannot, so any migration that is not reversible turns a fast rollback into a restore from backup.
What are the disadvantages of canary deployment?
It is not free, and the costs are worth naming before you commit to it.
- Two versions in production at once. Shared state, caches, queues and database schemas all have to tolerate both, which constrains what a single release can change.
- It needs real observability. Without per version metrics there is nothing to judge, and the canary becomes theatre.
- Low traffic sites learn little. Five percent of a hundred requests an hour is not a sample, it is an anecdote.
- Session affinity gets awkward. Users bouncing between versions mid session can see inconsistent behaviour unless the split is sticky.
- Someone has to own the abort rule. A canary without an automatic trigger depends on a human watching a dashboard, which does not survive contact with a Friday afternoon.
Do you need Kubernetes for canary deployments?
No. Kubernetes and service meshes make weighted routing convenient, but any reverse proxy that can split traffic will do the job. On a plain Linux server, nginx can send a fixed share of requests to a second upstream:
split_clients "${remote_addr}${http_user_agent}" $pool {
5% canary;
* stable;
}
upstream stable { server 127.0.0.1:8000; }
upstream canary { server 127.0.0.1:8001; }
server {
location / {
proxy_pass http://$pool;
proxy_set_header Host $host;
}
}
Hashing on the client address keeps a given visitor on one side of the split, which avoids the session inconsistency described above. Raising the share is an edit and a reload, and dropping back to zero percent is the rollback. The same idea applies with containers, where the split lives in the proxy in front of them rather than in the Docker deployment itself.
Canary deployment best practices
The teams that get real value from canaries tend to do the same handful of things.
- Define the abort rule before the rollout, not during it. Pick the metric, the threshold and the window while nobody is under pressure.
- Automate the rollback. The value of a canary is proportional to how fast it reverses without a human deciding.
- Compare canary against stable, in the same window. Absolute thresholds page you for normal traffic peaks.
- Keep releases small. When a canary aborts, a small release tells you exactly what caused it.
- Make migrations backward compatible. Otherwise the code rolls back and the schema does not.
- Watch background work too. Queue workers and scheduled jobs fail silently while every page still returns 200.
Where canary fits in the rest of your release process
A canary is one strategy among several, and it sits on top of a pipeline that already has to be sound. The release has to be atomic so a half copied deploy never serves traffic, the previous version has to stay on disk so rollback is a symlink switch rather than a redeploy, and the whole thing has to run without dropping requests in the first place. That foundation is what zero downtime deployment provides, and canary routing is the layer you add once it is in place.
For most teams running a handful of servers, the honest sequence is: get atomic releases and instant rollback working first, add real per version metrics second, and introduce traffic splitting last. Done in that order each step pays for itself. Done in reverse, you get a traffic splitter pointed at a deployment process that cannot reverse.
Ready to stop managing servers by hand? DeployManage provisions, deploys and monitors your fleet from one dashboard.
$ get started freeFrequently asked questions
What is a canary deployment?
A canary deployment is a release strategy that routes a small percentage of live traffic to a new version of an application while the rest continues to use the current one. The share is widened in stages only if error rate and latency stay healthy, so a bad release reaches a fraction of users instead of all of them.
What is the difference between canary and blue green deployment?
A canary shifts traffic gradually in percentage steps and needs only enough capacity for a small extra slice. Blue green runs two complete production environments and switches all traffic at once. Canary limits how many users see a bad release, while blue green gives a cleaner and faster on or off switch.
What is the difference between a canary deployment and a rolling deployment?
A rolling deployment replaces instances batch by batch until all of them run the new version, continuing unless something fails outright. A canary adds a deliberate checkpoint where real metrics decide whether to proceed, which catches problems like slow queries or memory leaks that never trigger a hard failure.
Is canary deployment the same as A/B testing?
No. A canary asks whether the new version is broken, runs for minutes or hours and is judged on error rate and latency. An A/B test asks whether a change performs better, runs long enough to reach statistical significance and is judged on conversion. They share a traffic splitter and nothing else.
How long should a canary deployment run?
Long enough to cover one full cycle of your slowest scheduled work, since bugs that only appear when an hourly job fires will otherwise be missed. For most web applications that means fifteen minutes to a few hours per stage. Canaries measured in days usually indicate weak instrumentation rather than caution.
What percentage of traffic should a canary get?
Start between 1 and 5 percent, then widen through roughly 25 and 50 percent before completing. The right first slice is whatever gives a statistically meaningful sample within your chosen window, so a low traffic site needs a larger percentage than a busy one to learn anything useful.
How do you handle database migrations during a canary deployment?
Both versions share one database, so every migration must be backward compatible for the whole rollout. Use expand and contract: add the new column, write to both, backfill, switch reads, and drop the old column in a later release. A destructive migration turns a fast rollback into a restore from backup.
What are the disadvantages of canary deployment?
Two versions run in production at once, so shared caches, queues and schemas must tolerate both. It requires per version observability to be worth anything, teaches low traffic sites very little, and can produce inconsistent sessions unless the split is sticky. It also needs an automatic abort rule rather than a watching human.
Do you need Kubernetes for a canary deployment?
No. Any reverse proxy that can split traffic will do it. On a plain Linux server, the nginx split_clients directive sends a fixed share of requests to a second upstream, and hashing on the client address keeps each visitor on one side. Kubernetes and service meshes make it more convenient, not possible.
What metrics should you monitor during a canary release?
Compare the canary against the stable version over the same window: HTTP 5xx rate, latency at the 95th and 99th percentiles, application error log volume, queue depth and job failures, and database load. Use percentiles rather than averages, because a badly broken endpoint barely moves the mean.
Can you automate a canary rollback?
Yes, and you should. Define the metric, threshold and observation window before the rollout begins, then wire the abort to drop the canary share to zero automatically. A canary that depends on somebody watching a dashboard stops working the moment a release lands late on a Friday.
Is canary deployment worth it for a small site?
Often not on its own. Five percent of a low traffic site is too small a sample to reveal anything, so the effort is better spent on atomic releases, instant rollback and decent error reporting. Canary routing pays off once you have enough traffic for a slice to be statistically meaningful.