Safe deploys and config changes
Most outages start with a change. Learn to ship code and config in small, watched steps, and to undo them fast.
Updated since you finished it. We changed this lesson after you marked it done. Your progress is kept.
What broke
On 2 July 2019 at 13:42 UTC, a Cloudflare engineer deployed a small change to a firewall rule. The rule was meant to catch cross-site scripting attacks. It had passed its automatic tests. 1
Within seconds the rule was on every Cloudflare server in the world. It contained a regular expression that backtracked badly. CPU use on the servers that handle web traffic jumped to nearly 100%. Visitors to Cloudflare sites got 502 errors, and Cloudflare lost about 80% of its traffic. 1
The rule was in "simulate" mode, so it was not meant to block anything. But even in that mode the rule still had to run, and running it was the problem. 1
Why did one rule reach everyone at once? Normal Cloudflare code went through staged rollouts. Firewall rules did not, by design, so that the team could respond fast to new attacks. 1
At 14:07 the team used a "global terminate" to switch off the firewall everywhere. Traffic came back at 14:09. One of the fixes they listed was to move rule changes to staged rollouts, like code. 1
It happens for real
Cloudflare · 2 Jul 2019Cloudflare outage: one regex used all the CPUFor about 27 minutes, visitors to Cloudflare sites around the world got 502 errors, and Cloudflare lost about 80% of its traffic. Google Cloud · 12 Jun 2025Google Cloud outage: blank policy fields crashed API checksFor hours, many Google Cloud and Workspace APIs returned 503 errors across the world, touching 76 Cloud products. CrowdStrike · 19 Jul 2024CrowdStrike outage: a content update crashed Windows hostsWindows machines running the Falcon sensor crashed to a blue screen, and many needed manual fixes to start again. Cloudflare · 18 Nov 2025Cloudflare outage: a feature file grew too bigFor several hours, many sites behind Cloudflare showed 5xx error pages, and dashboard logins and Access sign-ins also failed. Cloudflare · 5 Dec 2025Cloudflare outage: a global config change hit an old bugFor about 25 minutes, about 28% of the HTTP traffic Cloudflare served got 500 errors. All incidents tagged “config”The idea in simple words
Most outages do not start on their own. They start with a change. Google's SRE team writes that, in its experience, most incidents are triggered by binary or configuration pushes. 4
The key idea. Config is code. It changes how running systems behave, so it needs the same checks, the same slow rollout and the same fast undo as code.
A safe deploy has three parts:
- Check before you ship. Validate the change before it reaches any real server.
- Ship to a few first. Send the change to a small group, watch it, then go wider in steps.
- Undo fast. Make rollback one click or fully automatic, and practise it.
The goal is a small blast radius. If a change is bad, only a few users should see it, and only for a few minutes.
How it works
Step through a bad config change. Path A pushes it everywhere at once. Path B uses a staged rollout. Use Next and Back, or the ← and → keys.
- Path A, a global push. A new config passes its tests. The config system sends it to every server in every region within seconds.
- The config has a hidden bug that uses all the CPU. Every region fails at the same time, so every user is hit.
- Path B, a staged rollout. First, a machine validates the file: format, size and a quick speed test. Some bugs show up only on real traffic, so assume a few will pass.
- The config goes to the canary first: 1% of servers. During bake time, health checks compare the canary with the rest. Errors and CPU jump.
- The health check fails, so the system rolls the canary back and stops the rollout. The other 99% never got the bad config. A few users saw errors for minutes, not the whole world.
Now try it yourself. Push the same bad change both ways, and change how fast alerts notice.
Try it: push a bad config everywhere, or in stages
Validate the change first
Before any rollout, a machine should check the change. Does the file parse? Does it match the schema? Is it a normal size? Does a quick test on sample traffic stay fast? After the outage, Cloudflare planned speed tests for every firewall rule. It also planned to switch to a regex engine with run-time guarantees. 1
Validation catches simple mistakes. It does not catch every bug, so you still need the next steps.
Canary, then waves
A canary is a small part of the fleet that gets the change first. The rest of the fleet is the control. You compare the two: error rate, latency, CPU. 4
If the canary looks healthy, you go wider in waves. AWS describes a real pipeline: first one box in one zone, then one region, then groups of regions that get bigger each time. 3 In the first wave, AWS deploys to only one Availability Zone at a time. An Availability Zone is one of several separate locations inside an AWS region. Its top goal is to never hurt more than one region at once. 3
A simple percentage rollout follows the same idea: 1%, then 10%, then 50%, then 100% of servers or users.
Bake time and health checks
Bake time is how long you wait at each stage before going wider. Some bugs need time or real traffic to show up. The AWS pipeline waits at least one hour after each one-box stage. It waits at least 12 hours after the first wave of regions. 3
During bake time, automated health checks watch the metrics. If an alarm fires, the system rolls back on its own. No human has to wake up and decide. 3
Feature flags and kill switches
A feature flag lets you turn code on or off without a new deploy. 5 Ship new code switched off, then turn it on for 1% of users, then more. If it breaks, turn it off in seconds.
Flags also act as kill switches. On 29 May 2025, Google Cloud added new quota-checking code with no feature flag and no proper error handling. Nothing used it until 12 June. Then a policy with blank fields spread to every region within seconds. The code crashed on it. The team needed about 40 minutes to finish rolling out its "red button" fix. 2 Afterwards, Google said changes to critical binaries must be behind a flag that is off by default. It also said policy data must roll out in steps, with time to check each step. 2
Flags have a cost. Each one adds a branch to test. Remove a flag once the feature is fully on. 5
Trade-offs
| Approach | Small blast radius? | Speed to reach everyone | Use it when |
|---|---|---|---|
| Global push | No Every user at once. | Seconds. | A real emergency, like an active attack, and you accept the risk. |
| Canary, then waves | Yes A small group sees a bad change first. | Hours to days. | Most code and config changes. |
| Percentage rollout behind a flag | Yes You choose the share of users. | Minutes to days, your choice. | New features and risky code paths. |
| Blue-green (two full copies, switch traffic) | No All traffic moves at once. | Minutes. | You need a very fast undo, and you can pay for two copies. |
Simple rule: keep a fast global path only for emergencies, and make the slow staged path the default. Cloudflare's planned fix did the same: staged rollouts for rule changes, and a global push kept only for active attacks. 1
At work: how a senior uses this
- Ask about every change: "How do we undo this, and how long does it take?" If nobody knows, the change is not ready.
- Treat config, feature flags, firewall rules and data files as code. They need review, validation and a staged rollout.
- Ask "what is the blast radius?" A change that touches every region at once needs a very good reason.
- Name the metric that decides go or no-go before you deploy. Write it in the change ticket, for example "5xx rate above 0.5% on the canary means rollback".
- Make rollback automatic where you can. Test it on a normal day, not for the first time during an outage.
- Check that the tools you use to roll back do not depend on the system you are deploying. During the 2019 outage, Cloudflare engineers had trouble reaching internal tools. 1
- Ship big changes as many small ones. A small change is easier to check and easier to undo.
With AI
What to ask the agent
"Here is our deploy pipeline config. List every way a change can reach all production servers at once, including config and feature flags."
"Write a validation script for this config file. Check the schema, the size limits and the allowed values. Fail the build if any check fails."
"Add a canary stage to this pipeline: deploy to 1% of hosts, wait 30 minutes, and roll back if the 5xx rate or p99 latency rises."
What to check yourself
- The canary gets real traffic, and enough of it to show a problem.
- The rollback trigger uses metrics you trust, with clear thresholds.
- Rollback was tested, and it works when the new version is crashing.
- Config and data files go through the same stages as code, not a side path.
- New flags are off by default, and each has an owner and a plan to remove it.
Check yourself
Your progress is saved only in this browser. Export it to keep it safe.
You have finished 5 lessons. Your progress lives only in this browser. Export a copy so you don’t lose it.
Go deeper
Show 5 sources and related lessons
- Cloudflare, “Details of the Cloudflare outage on July 2, 2019” (official postmortem) (opens in a new tab)
The full timeline, why WAF rules skipped the staged rollout, and the list of fixes. - Google Cloud, Service Health incident report for 12 June 2025 (official) (opens in a new tab)
How code with no feature flag met policy data that spread to every region in seconds. - Clare Liguori, “Automating safe, hands-off deployments”, Amazon Builders' Library (opens in a new tab)
A real pipeline with one-box stages, waves of regions, bake times and automatic rollback. - Google, The Site Reliability Workbook (O'Reilly), chapter “Canarying Releases” (opens in a new tab)
What a canary is, how to compare it with the rest of the fleet, and why config changes need it too. - Pete Hodgson, “Feature Toggles (aka Feature Flags)”, martinfowler.com (opens in a new tab)
The kinds of feature flags, and why every flag has a cost until you remove it.
Real incident: Cloudflare, 2 Jul 2019: Cloudflare outage: one regex used all the CPU
Real incident: Google Cloud, 12 Jun 2025: Google Cloud outage: blank policy fields crashed API checks
Real incident: CrowdStrike, 19 Jul 2024: CrowdStrike outage: a content update crashed Windows hosts
Real incident: Cloudflare, 18 Nov 2025: Cloudflare outage: a feature file grew too big
Real incident: Cloudflare, 5 Dec 2025: Cloudflare outage: a global config change hit an old bug
Related: Feature flags and entitlements · CI/CD and trunk-based development · Observability, SLOs and error budgets · Incident response and postmortems
Related lessons: Feature flags, CI/CD and Incident response.