Courses / System Design Interview / Chapter 48
Module 11 · Wrap-up · Chapter 48 of 49
Lessons from Real System Failures
Builds on DNS: Turning Names into Addresses, Distributed Message Queues, Rate Limiters, Blob Stores and Design a Deployment System. Next up: Mock Interview: Four Timed Design Rounds.
Part 1 · How to read a postmortem
Why study other people's outages
Large outages usually start with an ordinary change, an ordinary tool or an ordinary assumption, and the companies involved often publish a detailed account. This chapter reads seven of those accounts and takes one design lesson from each.
A postmortem, also called an incident report, is a written review of an outage after it is over. It records what happened, how it was found and fixed, why it was possible, and what will change. Teams write them to learn, and customers read the public ones to judge whether to keep trusting the service.
For a person learning system design, public postmortems are the closest thing to a free look inside real systems. The earlier chapters introduced parts such as DNS, replication, queues and rollouts one at a time. An outage shows what happens when those parts interact, and it shows which of the assumptions behind them were wrong.
Every fact in this chapter comes from the company's own postmortem, named in each lesson. Dates, times and numbers are quoted as the report gives them, in the time zone the report uses. Where a report does not say something, this chapter does not say it either. That rule matters, because outside commentary on a famous outage is full of guesses that spread as facts.
What a postmortem contains
Google's site reliability engineering book describes the contents of a postmortem. It records the incident and its effect on users and services, the steps taken to reduce or fix the problem, the root cause or causes, and follow-up actions that lower the chance or the impact of a repeat. Public reports tend to cover the same ground, so it is a good checklist for reading one.
| Part | The question it answers | Where the lesson usually is |
|---|---|---|
| Impact | Who was affected, and for how long? | What the system's users actually lost |
| Timeline | When did it start, when was it noticed, when did it end? | The gap between the start and the detection |
| Trigger | What event set it off? | Usually small: a command, a file, a deploy |
| Root cause and contributing causes | Why could that event do so much damage? | Missing limits, missing checks, shared fate |
| Detection and response | How was it found, and what slowed the fix? | Broken tools, access problems, unclear ownership |
| Follow-up | What will change? | Guards, staged rollouts, tests |
The trigger and the cause are different things. The trigger is the event that started the incident, such as a mistyped number. The causes are the conditions that let that event become an outage. A typo is a trigger. A tool that accepts any number without checking it is a cause. Fixing only the trigger, for example by telling people to be more careful, leaves the cause in place for the next typo.
Reading for the design lesson
A good way to read a postmortem is to ask four questions in order.
- What was the blast radius? How much of the system could the single event reach? A change that reaches one server is a nuisance, and a change that reaches every region is an outage.
- What should have stopped it? Name the check, limit or delay that was missing or that did not work.
- What made it last? Look for slow detection, broken tools, or a recovery step that itself overloaded something.
- What changed afterwards? The follow-up list tells you what the authors think was missing.
The table lists the incidents of this chapter. The columns are only what each report says: when, what set it off, and what the lesson is for a designer.
| Incident | Trigger | Lesson for a designer |
|---|---|---|
| Amazon S3, February 2017 | A mistyped input to a removal command | Tools need safety limits |
| Cloudflare, July 2019 | A regular expression in a rule pushed globally | Roll out every change in stages |
| CrowdStrike, July 2024 | A content update to a sensor | Even data files are deployments |
| Google Cloud, June 2025 | Blank policy fields replicated worldwide | Validate, flag and stage global data |
| Facebook, October 2021 | A maintenance command disconnected the backbone | Do not let tools depend on what they manage |
| Amazon DynamoDB, October 2025 |
Part 2 · A command that removed too much: S3, 2017
What happened
On 28 February 2017, Amazon S3 in its US-EAST-1 region stopped serving requests for hours. AWS published a summary of the event.
According to that summary, the S3 team was debugging a slow billing process. At 9:37 AM Pacific time, a team member ran a command from an established playbook to remove a small number of servers from a subsystem that the billing process used. One of the inputs to the command was entered incorrectly, and a larger set of servers was removed than intended.
The removal took servers out of two other subsystems. The summary describes the index subsystem as managing the metadata and location information of all S3 objects in the region, needed for GET, LIST, PUT and DELETE requests. The placement subsystem allocates storage for new objects and is used during PUT requests, and it depends on the index subsystem. Both lost enough capacity that they needed a full restart, and S3 could not serve requests while they recovered.
The summary gives the recovery in stages. At 12:26 PM the index subsystem had enough capacity to serve GET, LIST and DELETE. At 1:18 PM it was fully recovered. At 1:54 PM the placement subsystem finished recovering and S3 was working normally. Some dependent services had built up backlogs and needed more time.
The blob store chapter described a metadata service and a placement role in a blob store. This incident is a reminder of how much depends on them: without its index, S3 could not serve requests.
What AWS changed
The report lists the fixes, and they are a good example of the difference between trigger and cause. The trigger was a wrong input. The causes were a tool that let one command take too much capacity out of a subsystem, and no rule that a subsystem must keep a minimum amount.
- The tool now removes capacity more slowly, so a mistake has time to be noticed before it becomes an outage.
- New safeguards stop a removal that would take a subsystem below its minimum required capacity.
- Other operational tools are being audited for similar safety checks.
- The work to split the index subsystem further into cells was moved up.
Notice that none of the four fixes asks operators to type more carefully. Each one changes the system so that the same typo is harmless. That is the standard to hold a follow-up list to.
The guard has two parts that do different jobs. A rate limit on removal bounds the speed of a mistake: even a wrong command can only do a little damage in one step. A minimum capacity floor bounds the size of a mistake: no command, right or wrong, can push a subsystem below what it needs to serve. The idea of a cell is a third guard, and a general technique. If an index were split into independent cells, each serving part of the keys, a failed cell would take out only its share.
A removal tool with and without a guard
The model has a fleet of three subsystems with invented sizes, and a minimum number of servers each needs to serve. The first tool removes whatever it is told. The second refuses to remove more than a quarter of a subsystem in one step, and refuses any removal that would leave fewer servers than the minimum.
FLEET = {"index": 50, "placement": 20, "billing": 12} # invented
MINIMUM = {"index": 40, "placement": 15, "billing": 4} # to serve
def remove_unguarded(fleet, name, count):
fleet[name] = max(0, fleet[name] - count)
return f"removed {count} from {name}"
def remove_guarded(fleet, name, count, step=0.25):
most = int(fleet[name] * step) # small steps, never a flood
if count > most:
return f"refused: {count} is over {most} at a time for {name}"
if fleet[name] - count < MINIMUM[name]:
return f"refused: {name} would drop below {MINIMUM[name]}"
fleet[name] -= count
return f"removed {count} from {name}"removal.py: the same operation, with and without a guard
The run gives both tools the same commands. The first is what the operator meant: remove 2 servers from billing. The second is the mistake, with the wrong subsystem and a count of 40. The guarded tool then gets two more commands: a legitimate removal of 10 from index, and a further 5. It was run with Python 3.12.10.
import sys from removal import FLEET, MINIMUM, remove_unguarded, remove_guarded print(sys.version.split()[0]) CMDS = [("billing", 2), # what the operator meant ("index", 40), # a wrong input: the wrong name and count ("index", 10), ("index", 5)] for label, remove, n in (("unguarded", remove_unguarded, 2), ("guarded", remove_guarded, 4)): fleet = dict(FLEET) print(f"-- {label} tool") for name, count in CMDS[:n]: said = remove(fleet, name, count) print(f"remove {count:2} from {name:9} -> {said}") ok = {k: fleet[k] >= MINIMUM[k] for k in fleet} print("fleet:", fleet) print("able to serve:", ok)
l2_run.py: one typo, two tools
3.12.10 -- unguarded tool remove 2 from billing -> removed 2 from billing remove 40 from index -> removed 40 from index fleet: {'index': 10, 'placement': 20, 'billing': 10} able to serve: {'index': False, 'placement': True, 'billing': True} -- guarded tool remove 2 from billing -> removed 2 from billing remove 40 from index -> refused: 40 is over 12 at a time for index remove 10 from index -> removed 10 from index remove 5 from index -> refused: index would drop below 40 fleet: {'index': 40, 'placement': 20, 'billing': 10} able to serve: {'index': True, 'placement': True, 'billing': True}
Part 3 · A change pushed everywhere at once
Cloudflare, July 2019
Cloudflare's report on 2 July 2019 describes an outage of about 27 minutes. A change to the managed rules of its web application firewall (WAF), which inspects requests for attacks, was deployed at 13:42 UTC. CPU use on the machines that served HTTP and HTTPS traffic rose to nearly 100 percent across the network, and customers saw 502 errors. Traffic and CPU were back to expected levels by 14:09 UTC, and the WAF was switched back on globally at 14:52.
The change was a new rule for detecting cross-site scripting that contained a regular expression, a pattern for matching text. The expression backtracked enormously. A regex engine that backtracks tries one way of matching, and when it fails it goes back and tries another. A pattern with stacked wildcards gives the engine so many ways to try that the time grows much faster than the length of the text. The report picks out the fragment .*.*=.* and shows step counts growing quickly as input lengthens.
The report names several contributing causes. The rule was deployed globally in one go, because the standard procedure allowed changes to WAF rules to skip the staged rollout used for other software. The rule was in simulate mode, but a rule in that mode still runs. A protection against CPU exhaustion had been removed by mistake in a refactoring weeks earlier. And the test suite checked that rules were correct but did not check how much CPU they used.
The follow-up list included bringing back the CPU protection, adding performance profiling of rules to the tests, moving to a regex engine with run-time guarantees such as RE2 or Rust's regex crate, and using staged rollouts for rules, with emergency global deploys kept for active attacks.
Run: backtracking against a linear check
Python's re module also backtracks, so it can show the same effect with a similar pattern. The program times .*.*=.*; on a string that has an = but no ;, so the match must fail after trying every split of the stacked wildcards. It doubles the input length each time and prints how much slower each step is. It also times a plain check of the same rule using str.find. The engine in the report is a different engine, so only the shape of the growth carries over. It was run with Python 3.12.10.
import re, sys, time print(sys.version.split()[0]) bad = re.compile(r".*.*=.*;") # stacked "match anything" parts def linear(s): # the same rule without a regex i = s.find("=") return i >= 0 and ";" in s[i + 1:] def timed(fn, text): t0 = time.perf_counter() fn(text) return (time.perf_counter() - t0) * 1000 print(f"{'n':>6} {'regex ms':>10} {'growth':>7} {'linear ms':>10}") prev = None for n in (100, 200, 400, 800, 1600): text = "x=" + "x" * n # no ';' at the end, so it fails ms = timed(bad.search, text) grow = f"{ms / prev:5.1f}x" if prev else " -" print(f"{n:6} {ms:10.2f} {grow:>7} {timed(linear, text):10.4f}") prev = ms
l3_run.py: stacked wildcards against a linear check
3.12.10 n regex ms growth linear ms 100 0.18 - 0.0017 200 1.36 7.7x 0.0022 400 9.53 7.0x 0.0022 800 67.73 7.1x 0.0067 1600 524.46 7.7x 0.0074
Times are on this machine and vary from run to run.
Each doubling of the input made the regex about seven times slower (other runs here gave between 5.6 and 8.3 times), which points to roughly cubic growth, since doubling the length of a cubic cost multiplies it by 8. At 1,600 characters it took over half a second for a single check. A server that checks every request against such a rule gets no work done. The linear check took about the same few microseconds throughout.
The fix has two layers. At the code level, use a matching engine that guarantees time proportional to the input, as the report's follow-up list says. At the process level, test new rules for run time, and put a limit on how much CPU one rule may use, which is the protection that the refactoring had removed.
CrowdStrike, July 2024
CrowdStrike's report concerns a content configuration update to its Windows sensor, released on 19 July 2024. The root cause analysis was published on 6 August 2024, and the company's page says that by 29 July about 99 percent of Windows sensors were back online. The point for a designer is in the name of the update. The page calls it a content configuration update, delivered through channel files, and not a new release of the sensor. Teams often stage code releases and push configuration and data more freely. A data file that a running program reads can break it as surely as code can, so it needs the same staged rollout. The root cause analysis itself was not opened for this chapter, so details of what the file contained are left out.
Google Cloud, June 2025
Google Cloud's incident report for 12 June 2025 describes a different route. A feature added to a component called Service Control on 29 May 2025 had no error handling and was not protected by a feature flag, and its code path was never exercised during the region-by-region rollout. At about 10:45 PDT a policy change containing unintended blank fields was written to regional database tables. Because that data is global, it replicated worldwide within seconds. Each region read the blank fields, hit a null pointer, and the binaries entered a crash loop.
The report's timeline shows a quick response: root cause found within 10 minutes, a switch to disable the code path ready in about 25 minutes, and rolled out within 40. Recovery then hit a second problem. In the us-central1 region, restarting tasks overloaded the database because Service Control did not use randomised exponential backoff, and recovery there took up to about 2 hours 40 minutes. Most products were fully recovered at 13:45 PDT. The first public notice came about an hour after the crashes began, because the status page itself was down, and some customers' monitoring that ran on the same cloud failed too.
The follow-up list includes propagating global data in increments with time to validate it, requiring feature flags that are off by default for critical changes, and keeping monitoring and communication systems independent of the platform they report on.
The regex in the Cloudflare run slowed about 7 times each time the input doubled. What does that growth tell you?
- It is roughly cubic: the time grows with the cube of the input length, far faster than the input.
- A guaranteed-linear engine avoids it.
Why does a content or configuration file need a staged rollout, as a code release does?
- A running program that reads it can fail on bad content, as with the sensor update.
- Data that reaches every machine at once has the same blast radius as a global code deploy.
What made recovery slower in Google's us-central1 region?
Part 4 · Cutting yourself off: Facebook 2021 and AWS 2025
Facebook, October 2021
Facebook's engineering post of 5 October 2021 describes how its services, and the tools used to repair them, went offline together.
The post says a routine maintenance command, meant to assess the capacity of the global backbone network, unintentionally disconnected all the backbone connections. The backbone is the network that links the company's data centres to each other and to the internet. A bug in the audit tool that should have stopped such a command did not stop it.
With the backbone gone, the data centres could not talk to each other or to the internet. DNS servers in smaller facilities withdrew their BGP advertisements because they could not reach the data centres. BGP is the protocol by which networks tell the rest of the internet which addresses they can reach. The name servers were still running, but now nobody on the internet could reach them, so the company's domain names stopped resolving.
The post describes what made recovery harder. Both the normal network and the out-of-band access used for emergencies were down. The loss of DNS broke many internal tools that engineers would use to investigate. Engineers had to go to the data centres in person, and the physical and system security that protects those sites made it slow to get in and change hardware. When connectivity returned, the services were brought back gradually to avoid power and traffic surges, and earlier drills of such surges helped.
The dns chapter explained that a name is only useful while its servers can be reached. Here a rule that withdrew the advertisement when the data centres looked unreachable turned a backbone fault into the loss of the company's names.
AWS and DynamoDB, October 2025
The AWS summary of 19 and 20 October 2025 describes a failure in the DNS management of Amazon DynamoDB in US-EAST-1. The summary says the cause was a latent race condition that left an empty DNS record for the regional endpoint, dynamodb.us-east-1.amazonaws.com. With no addresses behind that name, clients could not resolve or connect to the service.
Two automation components are involved. The DNS Planner watches the health and capacity of the servers that balance load and periodically creates a plan, a list of those servers with weights. The DNS Enactor applies plans to Amazon Route 53 using transactions, and it runs redundantly in three Availability Zones.
The summary gives the sequence. One Enactor was delayed while retrying updates on several endpoints. Meanwhile the Planner produced newer plans, and a second Enactor applied the newest plan quickly and then ran its clean-up, which deletes plans much older than the one just applied. The delayed Enactor then applied its stale plan over the newer one. Its check for whether its plan was newer had been made before the delay, so it was out of date when it acted. The clean-up then deleted that stale plan, which was now the active one. That removed all the addresses of the endpoint and left the system in a state that blocked further automated updates, so operators had to step in.
The times, in Pacific time: DNS failures began at 11:48 PM on 19 October. Engineers identified DynamoDB's DNS state as the source at 12:38 AM, restored some internal connectivity at 1:15 AM, and restored all the DNS information at 2:25 AM. Cached records expired and customer connections recovered by 2:40 AM. The report says AWS disabled both DNS automation components worldwide, and planned to fix the race and add protection against applying wrong plans before enabling them again.
What the two have in common
The two incidents look different, and they share one structure: a system that manages something depends on that thing, or acts on information that has gone stale.
| Facebook 2021 | DynamoDB 2025 | |
|---|---|---|
| Managed thing | The backbone network | The DNS record of an endpoint |
| Check that failed | An audit tool that should have stopped the command | A plan-is-newer check made before a delay |
| Dependence | Tools and DNS needed the network they were fixing | Further automated repair was blocked by the bad state |
| What slowed recovery | No access except in person | Manual intervention by operators |
Three design rules follow. First, a check must happen at the moment of the action. A check made, and then followed by a delay, tells you about the past. The usual fix is to make the check and the write one atomic step, as the rate limiter chapter did for a counter, or to carry a version number and have the store reject an older one. Second, repair tools must not depend on the thing they repair. The emergency path to a network should not need that network, and the monitoring of a platform should not live only on it. Third, automation that deletes needs limits. A clean-up job that can remove the record in use needs a rule that it never removes the newest or the active version.
This lesson has no program because both reports describe events inside systems that cannot be reproduced on one machine. The sequences are clear from the reports and are not recreated here.
Why did the company's DNS servers become unreachable in the Facebook outage?
Part 5 · Backups that were never restored: GitLab, 2017
The incident
GitLab published a postmortem of its database outage of 31 January 2017. The events it describes show how several small problems line up.
Around 19:00 UTC, database load rose, probably from spam, and part of it came from a job deleting an employee's data after an account was flagged by mistake. Around 23:00, replication to the secondary database fell behind and then failed, because the primary had already removed the log segments the secondary needed. An engineer started rebuilding the secondary by hand, and the rebuild command appeared to do nothing.
At around 23:30, the engineer meant to wipe the secondary's data directory and ran the command on the primary instead. About 300 GB of data had been deleted before the command was stopped. The report is plain about the human side, and it is also plain that the system allowed it.
What turned an error into a long outage was the state of the backups. The report lists four ways the company expected to recover and why each failed.
| Method | What was wrong |
|---|---|
| Daily dump to object storage | The storage bucket was empty. The dump program was an older version than the database and failed, and the failure emails were rejected, so nobody noticed |
| Disk snapshots of the cloud servers | Enabled for the file (NFS) servers but not for the database servers |
| Volume snapshots (LVM) | Made for copying data to a test environment, not for disaster recovery; the newest was a manual one about 6 hours old |
| Replication to a standby | Meant for failover and not for recovery, and its data had just been wiped in the rebuild |
GitLab recovered from the snapshot that was about 6 hours old. The report says that copying the data back took about 18 hours, limited by slow network disks of around 60 Mbps, and that the site was down for about 18 hours. Data created in the window between the snapshot and the outage, at least 5,000 projects, 5,000 comments and about 700 users, was lost. Git repositories and wikis were stored separately and were not affected.
A backup is not a backup until it is restored
The lesson of this report is a plain one: a backup you have never restored is a hope, not a backup. The dump job existed, so on paper there was a daily backup. In practice every run failed, and because the failure emails were rejected, nobody saw it.
A useful check does what a real recovery would do. It restores the backup into a scratch environment and compares what came back with what should be there. Cheaper checks are better than none, such as the age of the newest backup and its size, but each can pass while the backup is useless.
import sqlite3 TABLES = ("users", "projects") def make_source(): con = sqlite3.connect(":memory:") con.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name)") con.execute("CREATE TABLE projects (id INTEGER PRIMARY KEY, owner)") con.executemany("INSERT INTO users VALUES (?, ?)", [(i, f"user{i}") for i in range(1, 51)]) con.executemany("INSERT INTO projects VALUES (?, ?)", [(i, i % 50 + 1) for i in range(1, 121)]) con.commit() return con def counts(con): return {t: con.execute(f"SELECT COUNT(*) FROM {t}").fetchone()[0] for t in TABLES} def restore_test(dump, expected): scratch = sqlite3.connect(":memory:") try: scratch.executescript(dump) return counts(scratch) == expected except sqlite3.Error: return False
restore.py: a source database and a restore test
The model creates a small database with 50 users and 120 projects. It makes three backups: a complete dump, an empty file standing in for a dump job that failed and left nothing, and a dump cut off halfway. For each it runs three checks. One is that the file exists. One is that the file is not empty. The last is the restore test, which loads the dump into a fresh database and compares the row counts with the source.
import sys from restore import make_source, counts, restore_test print(sys.version.split()[0]) src = make_source() good = "\n".join(src.iterdump()) backups = {"complete": good, "empty file": "", "cut off halfway": good[:len(good) // 2]} print(f"source rows: {counts(src)}") print(f"{'backup':16} {'exists':>6} {'non-empty':>9} {'restores':>8}") for name, dump in backups.items(): ok = restore_test(dump, counts(src)) row = (dump is not None, len(dump) > 0, ok) print(f"{name:16} {row[0]!s:>6} {row[1]!s:>9} {row[2]!s:>8}")
l5_run.py: three backups, three checks
Reading the run, and the quiz
3.12.10 source rows: {'users': 50, 'projects': 120} backup exists non-empty restores complete True True True empty file True False False cut off halfway True True False
The existence check passed for all three, so it proved nothing. The non-empty check caught the empty file and passed the file that was cut off halfway. Only the restore test told the three apart: it passed the complete dump and failed the other two. The cut-off file is the dangerous one, because it looks like a real backup and only fails when someone depends on it.
The restore test should run on a schedule, and it should raise an alarm that someone is sure to see. In the incident, the failure emails were rejected and so never arrived. Alerts need a test of their own: a deliberate failure that you confirm reaches a person.
The wider lesson is that every recovery method has two properties, that it works and that you know it works, and only practice gives the second. The same holds for failover to a standby, for rebuilding a server from scratch and for switching to another region. Teams that rehearse these find the gaps before an outage does.
Why did the existence check in the run prove nothing?
- It passed for the complete dump, the empty file and the cut-off dump alike.
- A file existing says nothing about whether it can be restored.
Which backup did the non-empty check wrongly accept, and which check caught it?
- The dump cut off halfway: it is not empty, so it passed.
- The restore test caught it, because the restored row counts did not match.
The failure emails of the dump job were rejected. What does that teach about alerts?
- An alert that cannot reach anyone is the same as no alert.
- Test the alert path by causing a deliberate failure.
Part 6 · The patterns that keep coming back
Staged rollouts
Several incidents in this chapter reached far more of the system than they needed to, and the remedy is the same: stage every change. Send it to a small slice first, watch, and widen the slice only if it is healthy. The deployment system chapter set out the strategies, with a canary, bake time and waves. Here the question is what staging would have changed in these reports.
In the Cloudflare report, a rule was deployed globally because the procedure exempted rules from staging. In the Google Cloud report, a policy change reached every region in seconds, and the report's own follow-up calls for incremental propagation with time to validate. In both, a small first stage would have shown a crash loop or a CPU spike on a few machines and not on the whole fleet.
Watch for the bad change stopping at the canary, before it spreads
Read it as steps
A bad change meets a canary and stops, against a push to every region.
The model below has 1,000 servers and four waves of 10, 90, 400 and 500, with a health check after each wave that halts if more than 2 percent of that wave fails. A good change and a bad change each go out two ways, in stages and all at once. A bad change fails every server it reaches.
What the rollout run shows
3.12.10 good change, all at once everywhere updated 1000 failing 0 servers hurt: 0 of 1000 good change, staged canary updated 10 failing 0 wave 1 updated 100 failing 0 wave 2 updated 500 failing 0 wave 3 updated 1000 failing 0 servers hurt: 0 of 1000 bad change, all at once everywhere updated 1000 failing 1000 servers hurt: 1000 of 1000 bad change, staged canary updated 10 failing 10 halt: 100% of canary failed servers hurt: 10 of 1000
A good change reaches all 1,000 servers either way, so staging costs only time. A bad change pushed all at once hurt 1,000 servers. The same bad change in stages stopped at the canary and hurt 10, one percent of the fleet. The price of staging is the delay of the waves, and the price of its absence is the whole blast radius.
The Google Cloud report names a second mechanism, a kill switch: a way to turn off a code path quickly without deploying new code. The report describes a "red button" that disabled the failing path, ready in about 25 minutes and rolled out within 40. A kill switch is a flag that is checked on the hot path and can be changed fast. It is useful only if it exists before the incident, if it covers the risky feature on its own, and if flipping it is routine and tested.
Two principles come from the Google Cloud report. New behaviour should be behind a flag that is off by default, which Google lists as a follow-up for critical changes. And data that every region reads must propagate gradually: the report lists replicating global data in increments, with time to validate it, as a follow-up.
Retry budgets and tested restores
The Google Cloud outage had a second act. Restarting tasks overloaded a database because the service did not back off with randomness. The message queue chapter introduced retries with backoff and jitter. The site reliability engineering book's section on cascading failures adds the limit that matters at scale: retries must be bounded per request and also bounded overall, with a retry budget. It gives an example of 60 retries per minute for a process, after which a failing request is returned without retrying.
The same chapter points out that retries multiply across layers. If three layers each make four attempts, the database receives 4 x 4 x 4 = 64 attempts for one user request. The chapter advises retrying only at the layers that need it.
import random random.seed(2) REQUESTS, TRIES = 1000, 3 # a dependency is down for a minute def attempts(budget): total, spent = 0, 0 for _ in range(REQUESTS): total += 1 # the first try always happens for _ in range(TRIES): # every try fails if budget is not None and spent >= budget: break spent += 1 total += 1 return total print("requests:", REQUESTS) print("calls with up to 3 retries each:", attempts(None)) print("calls with a budget of 60 retries:", attempts(60)) print("three layers, 4 tries each:", 4 ** 3, "calls on the database")
l6b_run.py: the cost of retries with and without a budget
requests: 1000 calls with up to 3 retries each: 4000 calls with a budget of 60 retries: 1060 three layers, 4 tries each: 64 calls on the database
A dependency that is down for a minute receives 1,000 requests. With up to three retries each, that is 4,000 calls, four times the load on something already failing. With a budget of 60 retries, it is 1,060. The arithmetic for three layers gives 64 calls. The model is simple and the effect is the one the report warns about: retries multiply a failure when they are unbounded.
The last pattern, a tested restore, comes from the previous lesson. The table shows how the chapter's incidents map to the four patterns.
| Pattern | Incidents it addresses |
|---|