05.3.4 · Skill in Controlled releases

Canary releases

Running a new version on a small slice of traffic first.

A canary release deploys new code to a small part of the infrastructure and compares its error rate and latency with the rest. If the canary looks unhealthy, it is pulled. It catches technical problems before most users meet them.

Your status · Canary releases

Saved in this browser. Sign in to keep it on every device.It colours this skill's tile on your map.

Why it matters for a product engineer

A canary release sends a new version to a small part of the traffic first and compares it with the rest. If it is unhealthy, it is removed before most users meet it. It turns a bad release from an outage into a small dip that only shows on a graph. For a small team, it is one of the cheapest ways to make releases safe.

How to do it

  1. Deploy the new version to a small share of servers or users, such as 1% to 5%.
  2. Compare the canary with the rest on the same metrics: errors, latency, CPU, key user actions. Split the graphs by version. Mixed together, a bad canary disappears into the average.
  3. Wait long enough to see real traffic, including the slow paths.
  4. Decide with a rule written in advance: continue, wait or roll back. Automate it where you can.
  5. Widen in steps, and keep the way back open at each step.
  6. Keep a separate path for real emergencies, and use it only for them.

Common mistakes

  • A canary too small or too short to see anything.
  • Watching only the global average.
  • A canary with no automatic way back.
  • Skipping the canary for “small” changes, such as configuration or rules.

Example

On 2 July 2019, a Cloudflare engineer deployed a minor change to a firewall rule. Rules went out worldwide in seconds, with no staged rollout, because they exist to stop new attacks. The rule exhausted the CPU on Cloudflare’s edge and took the service down for 27 minutes. Before turning the firewall back on, the team tested the fix in one city, on part of the traffic. Afterwards, rule changes moved to staged rollouts, with a global push kept for active attacks.

Timeline

Cloudflare's outage of 2 July 2019, in UTC

  1. 13:42A rule change goes out worldwideShippedTests passed. The change reached every server in seconds.
  2. 13:45First alertProblemThen failing end-to-end tests, a global traffic drop and 502 errors.
  3. 14:07Firewall turned off worldwideDecisionA "global terminate" for one component.
  4. 14:09Traffic and CPU back to normalResult
  5. 14:52Firewall back onShippedAfter testing the fix in one city, on part of the traffic.

The fix was tested the way the change should have shipped: small first. Rule changes now use staged rollouts.

ReportedCloudflare, 'Details of the Cloudflare outage on July 2, 2019'

Sources: Details of the Cloudflare outage on July 2, 2019 (Cloudflare) ↗ · Canarying releases (The Site Reliability Workbook, chapter 16, Google) ↗

Resources

2

Tools

4
Tools for Controlled releases