Canary Release: Test New Code on Real Users, Safely
A canary release is like sending a canary into a coal mine: expose a new version to a small group of users to detect problems before a full rollout. It's used to safely test changes in production by gradually shifting traffic.
WHY IT EXISTS: Big-bang deployments, where a new software version replaces an old one all at once, are inherently risky. A single bug can cause a site-wide outage, affecting all users and making rollback difficult. Canary releases were created to solve this by drastically reducing the blast radius of a bad deploy.
THE MENTAL MODEL: Think of the old mining practice of carrying a canary in a cage. If dangerous gases leaked into the mine, the canary would succumb first, giving the miners an early warning to evacuate. A canary release uses a small subset of users as the "canary" to detect problems with a new software version before it impacts the entire user base.
HOW IT WORKS: You deploy the new version alongside the existing stable version, but initially route no traffic to it. Then, you configure your router or load balancer to direct a small percentage of users—say, 1%—to the new version. You can select these users randomly, by region, or by targeting internal employees first. You monitor key metrics like error rates and latency. If the new version performs well, you gradually increase the traffic (e.g., to 5%, 20%, 50%, and finally 100%). If any issues arise, you simply route all traffic back to the old version, providing a safe and instant rollback. Once 100% of traffic is on the new version and it's stable, you can decommission the old infrastructure.
WHEN TO USE IT: Use canary releases to reduce the risk of introducing a new version with bugs or performance regressions. It's ideal for web services where you control the backend and can easily manipulate traffic routing. It also serves as a form of live capacity testing, as you can observe how the new version behaves under increasing real-world load.
WHEN NOT TO USE IT: Canary releases are difficult for software installed on user devices, like mobile apps or desktop clients, because you have less control over when users upgrade. Also, do not conflate it with A/B testing. A canary's goal is to quickly validate stability (minutes to hours), whereas an A/B test is a longer-running experiment to test a business hypothesis (days to weeks). Using a canary for A/B testing can pollute the results and delay the release.
ONE CANONICAL EXAMPLE: Facebook uses a multi-stage canary strategy. A new version is first released internally to its own employees with all feature flags enabled. This internal "canary" catches many issues before any external users are exposed. Only after it passes this stage does the rollout proceed to small percentages of the public user base.
Read the original → martinfowler.com
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.