Blue-green vs canary deployment, and how long a canary has to run

Blue-green limits how long a bad release lasts; a canary limits how many users it reaches. A canary works only if its slice sees enough requests to tell a regression from noise.

Andrei Gaspar

Editor, How They Ship · · 10 min read

Share
Circle, cream card and pill in amber, teal and charcoal

A blue-green deployment moves all traffic to the new version at once and keeps the old one ready to switch back. A canary deployment sends a slice of real traffic to the new version and compares it with the rest. Blue-green limits how long a bad release lasts, and a canary limits how many users it reaches.

Cloudflare had both kinds of path on December 5, 2025. Its engineers were rolling out a larger request-body buffer for the firewall through the company's gradual deployment system. Partway through, they noticed that an internal testing tool did not support the new size and switched the tool off with a second change. That second change went through Cloudflare's global configuration system. According to the postmortem, that system "does not perform gradual rollouts, but rather propagates changes within seconds to the entire fleet of servers in our network". The change reached the network at 08:47 UTC and was fully propagated by 08:48. It set off a bug in Cloudflare's older proxy. Sites served by that proxy with the managed firewall rules returned HTTP 500 errors until the revert finished at 09:12. Cloudflare put the affected customers at about 28% of all the HTTP traffic it serves.

The first change was on the safe path and the second was not, so the canary that existed never saw the change that broke things. That is one way a canary fails. The other way is quieter, because the change does go through the canary, but the canary is too small or too short to notice anything. This piece covers what each method tells you before everyone has the new version, and then works out how many requests and how many minutes a canary needs before its verdict means anything.

How a blue-green deployment works

Martin Fowler's description from 2010 is still the standard one. A team keeps two production environments that are as identical as possible. One of them, say blue, serves all traffic. The new release goes to green, where the team runs its final tests. When the release works there, the router sends all incoming requests to green, and blue sits idle. In Fowler's words, "Blue-green deployment also gives you a rapid way to rollback", because undoing the release means switching the router back.

The strength of the method is the switch. Rollback is a routing change, not a redeploy, so it takes as long as the router takes to apply it. The idle environment is also a safe place to warm caches and run smoke tests against production configuration before any user arrives.

The weakness is in what the team learns before the switch. Green has been tested, but it has not served real users. Every user moves to the new version at the same moment, so a defect that only real traffic triggers reaches all of them at once. Blue-green makes that defect short-lived if someone notices it quickly, but it does nothing to make the defect small. Fowler also notes a cost that has not gone away. If the team switches back, the transactions that happened while green was live still have to be dealt with. A shared database usually means the schema has to work with both versions at the same time, which is the same constraint any staged rollout has.

How a canary deployment works

A canary changes what the team learns first. Danilo Sato's entry on canary release describes it as reducing risk "by slowly rolling out the change to a small subset of users before rolling it out to the entire infrastructure". The new version serves a slice of production, and the team watches that slice before giving it more traffic. If something looks wrong, traffic goes back to the old version.

The comparison is what makes it work. Google's Site Reliability Workbook treats canarying as an A/B test, with the canary as one group and the rest of production, still on the old version, as the control. The control matters because production changes on its own all the time. Traffic rises at lunchtime, a dependency slows down, a batch job starts. A canary that is compared only with yesterday's numbers will blame the release for things that happened to everyone, and miss things that the release really did.

So a canary answers a different question from blue-green. Blue-green asks whether the new version passes its tests and whether the team can switch back fast. A canary asks whether the new version behaves like the old one on real traffic, measured side by side. The answer to that question depends on how much traffic the canary sees, which is where most canaries quietly fall short.

Canary size and the error budget

The workbook works through a small example. Suppose a release fails 20% of requests. Deployed to everyone, it fails 20% of all traffic. Deployed as a canary to 5% of the population, "we serve 20% errors for 5% of traffic, resulting in a 1% overall error rate". The canary has cut the damage to a twentieth, and the workbook's point is that the cost to the error budget is proportional to the share of traffic exposed to the defect.

The same arithmetic shows the trap. If the team's dashboards show the service as a whole, the bad release appears as a 1% error rate, which may look like an ordinary bad minute. The workbook makes this point directly. Monitoring that looks at the whole system sees only the 1%, and the 20% failure on the canary is visible only when the metrics are split by population, canary against control. Amazon's Builders' Library describes the same problem for its one-box stage, which serves a small percentage of traffic and so may not trip the service's main alarm. Its answer is a second alarm scoped to the requests that the one box served.

A canary's size therefore pulls in two directions. A smaller slice protects more users from a bad release. It also collects fewer requests per minute, so it takes longer to show anything that is not a disaster. A release that fails 20% of requests is easy to see on any slice. The releases that reach production are rarely that obvious, and the next section works out what a smaller regression needs.

How long a canary has to run

The workbook states the principle in general terms. A canary should be large enough and run long enough to be representative, and "the higher the processing rate, the less time is required to get a representative sample". To turn that into minutes, we need numbers, so here is an illustration with invented inputs. Suppose a service handles 20 requests per second, and its current version fails 0.2% of requests. A new release has a bug that doubles the error rate to 0.4%. The team runs a 5% canary and watches it for five minutes.

In those five minutes the canary serves 300 requests. At the old error rate, it would show 0.6 errors. At the new one, it would show 1.2. Both numbers round to one error at most, and no comparison can separate them. The canary passes because it never had enough traffic to fail. Our piece on what good teams stop doing made this point in one paragraph, when it weighed a canary against a staging environment. Here is the arithmetic behind it.

To find how much traffic it does need, we used a standard sample-size calculation for one error rate against a known baseline. We set it to raise a false alarm on a good release no more than 5% of the time and to catch a real regression 80% of the time. The script is at the end of this piece. For the service above, it gives the following.

Regression in the illustrationCanary requests needed1% slice5% slice20% slice
0.2% to 0.4% (errors double)4,010334.2 minutes66.8 minutes16.7 minutes
0.2% to 0.3% (errors rise by half)14,2911,190.9 minutes238.2 minutes59.5 minutes

The table shows why five minutes on a 5% slice is not a rule. In this illustration, catching a doubled error rate on a 5% slice takes about an hour, and catching a 50% rise takes about four hours. The same calculation for a service ten times busier, at 200 requests per second, divides every time by ten, so the 5% slice needs 6.7 minutes for the doubled rate. The request count does not change with traffic, only the time it takes to collect. The useful way to size a canary is therefore to decide how small a regression it must catch, work out how many requests that takes, and let the traffic decide the minutes.

The calculation is a simplification. It looks at one metric, treats every request as independent and assumes the old version's error rate is known from the much larger control. Real systems compare many metrics, traffic changes over the day, and some defects only appear under peak load. The workbook warns about time of day for that reason, since performance defects tend to show up only under heavy load. Each of those factors makes a canary need more time, not less.

Amazon builds the same idea into its pipelines with both a clock and a count. In the 2020 Builders' Library article, Clare Liguori describes a typical pipeline that waits at least one hour after each one-box stage, at least 12 hours after the first regional wave, and at least two to four hours after each later wave. The bake time also requires a minimum number of data points, for example "wait for at least 100 requests to the Create API", so that a quiet hour does not count as a test. The cost is speed. Liguori writes that the default bake times are conservative and take a change to all regions in about four or five business days.

Using blue-green as a canary

The two methods are not a strict choice. The workbook describes running both environments at once instead of one at a time. The new version goes to the standby environment, and traffic is split between the two by a weight that rises over time. "You can use blue/green deployments more or less as normal canaries by utilizing both blue and green deployments simultaneously (rather than independently)," it says. The live environment becomes the control, the standby becomes the canary, and the traffic weight sets the size of the canary population.

This keeps the strength of blue-green, because rollback is still a routing change, and adds the strength of a canary, because only part of the traffic sees the new version at first. It also inherits the canary's arithmetic. A 1% weight on the new environment is a 1% canary, and it needs the same number of requests as any other 1% canary before its verdict means anything. The team also needs the two environments' metrics side by side, split by environment, or the comparison is lost in the totals.

Where this check sits among the other verification stages of a release is the subject of The anatomy of a release cadence. For a team choosing between the two methods, the practical question is how it will compare the new version with the old one on real traffic, and for how long. Blue-green with an instant cutover skips that comparison and relies on a fast switch back. A canary, or blue-green with a gradual weight, makes the comparison, and its value depends on the request count behind it.

Configuration changes need a canary too

Cloudflare's outage on December 5 was not a code release. It was a configuration change, and the system it went through had no gradual rollout at all. Seventeen days earlier, on November 18, a larger outage had the same shape. A database permissions change made a Bot Management feature file double in size, and Cloudflare's postmortem describes how that file was propagated to every machine on its network, where the proxy failed on it.

Amazon treats this kind of change as a deployment. Liguori's article lists runtime configuration, such as API rate limit increases and feature flags, among the sources that go through pipelines with the same safety mechanisms as application code, including automatic rollback. A flag flip or a rate-limit change can break production as surely as new code, and it can reach every server faster than code can.

Cloudflare reached the same conclusion. In May 2026 it reported the end of a program it called "Code Orange: Fail Small". "In most cases, Cloudflare internal configuration changes no longer reach our network instantly and are instead rolled out progressively with real-time health monitoring," the post says. The mechanism is an internal system called Snapstone, which packages a configuration change and releases it gradually with health checks and automatic rollback. Cloudflare states that if the November change were rolled out now, the system would catch it before it had affected more than a small percentage of traffic. That claim is Cloudflare's own, but the design behind it is the one this piece describes, in which a slice of the fleet gets the change first and is compared with the rest before the change goes further.

What to do on Monday

Cloudflare had a gradual deployment system on December 5. The change that broke the network never went through it, and the instant path took one minute to reach the whole fleet. The first question for any team is therefore which changes skip the canary, and the second is whether the canary they do have can see anything.

  • List every path a change can take to production, including configuration systems, feature-flag consoles and data files, and mark which ones have a gradual rollout. Any path without one is where the next incident like December 5 comes from.
  • For your last release, find how many requests the canary served before it was promoted. Then use the script at the end of this piece with your own traffic and error rate to see what size of regression that request count could have caught.
  • Check that your canary alarms read metrics split by canary and control. If the only alarm watches the whole service, a 5% canary that fails 20% of requests shows up as a 1% bump.

A canary is only as good as the traffic it sees and the changes that go through it, and both of those are numbers a team can check this week.

The script

The numbers in the table come from the script below. It assumes one error metric, independent requests and a baseline error rate known from the control. Run it with no arguments for the illustration's service at 20 requests per second, or pass your own traffic, as in python canary_size.py 200, and edit BASELINE and the two regressions at the top for your service.

"""How long must a canary run to see an error-rate regression?
 
Illustrative only: the traffic and error rates are assumptions, not
measurements. One metric (the error rate), requests treated as independent,
and the old version's error rate taken as known from the much larger control.
"""
import math
import sys
 
RPS = float(sys.argv[1]) if len(sys.argv) > 1 else 20     # service traffic, requests per second
BASELINE = 0.002          # error rate of the current version: 0.2%
Z_ALPHA = 1.645           # one-sided 5% false alarm rate
Z_POWER = 0.842           # 80% chance of catching a real regression
SLICES = [0.01, 0.05, 0.20]
 
 
def requests_needed(p0, p1):
    """Canary requests needed to tell error rate p1 from a known baseline p0."""
    root = Z_ALPHA * math.sqrt(p0 * (1 - p0)) + Z_POWER * math.sqrt(p1 * (1 - p1))
    return math.ceil((root / (p1 - p0)) ** 2)
 
 
print(f"Service at {RPS:g} requests/second, baseline error rate {BASELINE:.1%}\n")
 
print("What a 5% canary watched for 5 minutes sees:")
seen = RPS * 0.05 * 5 * 60
print(f"  {seen:,.0f} requests, {seen * BASELINE:.1f} errors expected from the old code's rate\n")
 
for bad in (0.004, 0.003):
    n = requests_needed(BASELINE, bad)
    print(f"Regression to {bad:.1%}: the canary needs {n:,} requests")
    for share in SLICES:
        minutes = n / (RPS * share) / 60
        print(f"  {share:>4.0%} slice: {minutes:6.1f} minutes")
    print()

Its output for the illustration, at 20 requests per second:

Service at 20 requests/second, baseline error rate 0.2%
 
What a 5% canary watched for 5 minutes sees:
  300 requests, 0.6 errors expected from the old code's rate
 
Regression to 0.4%: the canary needs 4,010 requests
    1% slice:  334.2 minutes
    5% slice:   66.8 minutes
   20% slice:   16.7 minutes
 
Regression to 0.3%: the canary needs 14,291 requests
    1% slice: 1190.9 minutes
    5% slice:  238.2 minutes
   20% slice:   59.5 minutes

Andrei Gaspar

Editor, How They Ship

This blog exists thanks to the support of our sponsors:

GitdailiesQA.techAppSignalSuperlinked
Become a sponsor

Comments

Loading comments…

Subscribe

How engineering teams actually ship

A closer look at how the best teams ship. Twice a month.

We’ll email you a confirmation first. Your address is used only to send you this newsletter, and every issue has an unsubscribe link. Privacy policy

Keep reading