← the whole book on one page

Chapter 5: Designing for Failure — Stability Patterns and Chaos Engineering

“A distributed system is one in which the failure of a computer you didn’t even know existed can render your own computer unusable.” — Leslie Lamport

Every system fails. Some fail in small pieces and some fail all at once, and the difference between the two is rarely a matter of luck. When a failure stays small, it is usually because someone designed it to: an engineer imagined that particular failure in advance and drew a line it could not cross, such as a timeout, a partition, or a limit on how much one part may ask of another. When a failure spreads, it has usually found a path that was built for some other purpose, a channel that exists so that the parts can cooperate, and very often a path that was built for recovery. That second observation is the uncomfortable one, because it means the machinery we add to help a system heal itself can become the road along which its sickness travels. This chapter is about both kinds of structure, the lines that contain failure and the paths that carry it, and about how to find out, on a day of our own choosing rather than the failure’s, whether the lines actually hold.

Our field offers no clearer lesson than the events of 15 January 1990, when AT&T’s long-distance network spent about nine hours unable to complete a great many of its calls. Nothing physical had broken. Weeks earlier the company had installed new software on its 114 4ESS switches, and the change touched one particular routine: the code that ran when a switch recovered from a fault and told its neighbors that it was back in service. In that C code, a break statement inside an if clause, which was itself inside a switch statement, ended the enclosing block too early. For weeks the flaw lay quiet, because the code containing it ran only during recovery, and recovery was rare. Then one switch in New York suffered a minor fault and, on returning to service, sent its neighbors the usual recovery messages. A neighbor that received a second such message while it was still handling the first stepped onto the defect, corrupted its own data and reset itself. When that neighbor came back, it did exactly what a well-behaved switch should do and announced its own recovery, and its neighbors fell over in turn. The cascade rolled across the network in this way, as Figure 5.1 shows, until engineers reduced the signaling load enough for the switches to settle, and then reinstalled the previous version of the software.

The AT&T cascade, 1990 Left: a map of switches joined to their neighbors, with the first switch, in New York, at the centre and the waves of resets spreading outward from it. Right: the loop each switch ran. A switch recovers and tells its neighbors it is back in service; a neighbor that receives a second message while still handling the first hits the defect, corrupts its data and resets; when it recovers, it becomes the next sender. IT IS NOW THE SENDER Switch recovers returns to service Neighbors get messages a second while busy Defect fires break exits too early Neighbor resets data corrupted WAVE 1 WAVE 2 WAVE 3 NEW YORK · MINOR FAULT "back in service" trigger: one switch, one minor fault The trigger lasted seconds; the loop ran for about nine hours. All 114 switches ran the same code, so redundancy could not help. The first switch Switch or step The recovery loop that sustained the outage

Figure 5.1 — The AT&T cascade of 15 January 1990. Each switch’s recovery announcement reset its neighbors, and each reset produced the next announcement. The loop that sustained the outage is the recovery path itself.

It is worth slowing down to see why so carefully engineered a network behaved this way, because the reasons reach far beyond telephony. Every switch had been built to recover from its own faults, and that design rested on an assumption so natural that it was rarely stated: that failures would be independent, so that while one switch was recovering, its neighbors would be healthy. But all 114 switches ran the same code, and so they shared the same defect. Worse, the defect sat in the recovery path, which is the code that runs least often and matters most when it does run, and which is therefore the code least likely to have been exercised before the day it is needed. Notice also what did not cause the outage. There was no flood of ordinary calls; what kept the failure alive was a feedback loop inside the switches’ own protocol, in which each recovery produced the messages that caused the next crash, so the loop fed itself. From this follows a lesson we will return to throughout the chapter. Redundancy protects us against independent failures, such as one machine’s disk wearing out while its twin’s does not, and it does nothing at all against common ones. A fleet running identical software is, for the purposes of its defects, one machine.

Encore learned a smaller version of the same lesson early in its life. Its first big outage began when the payment service provider (PSP), the outside company that actually moves the money for each ticket, slowed from its usual 200 ms to 8 s. Nothing inside Encore had failed, and yet the slowness spread: requests waiting on the PSP filled the connection pools, services with full pools began failing their health checks, the autoscaler’s response made matters worse rather than better, and clients retrying their failed requests turned a slow dependency into a storm. It was a cascade of reasonable defaults, each sensible on its own and ruinous together, and in that respect it rhymes with AT&T’s switches, where every component also did what it had been designed to do. The Architecture book told that story and named the patterns that answered it, among them retry budgets and a single layer of retries. Naming a pattern, though, is the easier half of the work. A timeout has to be set to some particular number, a breaker has to be tuned, and a wall between components has to be checked to see whether it still holds after a year of releases. This chapter is about operating those patterns. It begins where cascades begin, at the boundaries between components (Section 5.1). It moves to the mechanisms that keep a caller from drowning when a callee slows (Section 5.2), and to what a service should do when it is simply asked for more than it can give (Section 5.3). It widens to the walls that limit how much of the system a single failure can reach (Section 5.4). And it ends with the practice of testing all of these on purpose, through the quarterly game days run by the Reliability team, Encore’s ten site reliability engineers (Section 5.5). (The map of Encore in Chapter 1 shows where each piece sits.)

5.1 Integration Points and Cascading Failure

Where faith is required

An integration point is any place where one component depends on another across a boundary it does not control: a network call, a shared database, a queue, a third-party API. Inside a single process, a function call either returns or throws, and the caller learns which. Across a boundary that certainty disappears. Michael Nygard called integration points the number-one killer of systems, and the reason is structural rather than a matter of bad luck or careless vendors. A call across a boundary can hang forever. It can return an answer that is well formed and wrong. Worst of all, it can succeed on the far side while the caller concludes that it failed: a PSP may take a fan’s money a moment after Orders & Payments has stopped waiting for the reply. In every one of these cases the caller sees much the same thing, silence or an error, and has no means of telling which story is true. What a component cannot verify, it must take on faith, and so every integration point is a place where our system extends trust to a party whose behavior we neither see nor control.

That faith would matter less if failures stayed where they started. They do not, and the opening of this chapter showed why. A cascading failure is one in which the failure of one component raises the load or latency on the components that depend on it until they fail too, so that the damage travels outward along the dependency graph. The AT&T switches passed their failure along a recovery protocol; most cascades in ordinary systems travel along integration points, from callee to caller, one hop at a time.

It is tempting to think the most dangerous dependency is the one that dies, but I have come to believe the opposite: the most dangerous integration point is the one that has slowed down rather than stopped. A dead dependency refuses quickly. The connection is rejected in a millisecond, the caller gets a clear error, and whatever fallback exists can run at once. A slow dependency is far more costly, because it holds a thread, a connection and a queue slot for as long as we are willing to wait, and software left to its defaults is willing to wait a very long time. A little arithmetic shows how fast this goes wrong. The number of calls in flight is the arrival rate multiplied by the time each call takes, the relation Little’s law gives us. When Encore’s PSP slowed from 200 ms to 8 s in that first outage, each payment call began occupying its connection 40 times longer. At an unchanged rate of purchases, Orders needed 40 times as many connections open at once just to keep pace. That is why, as the opening of this chapter recounted, the pools emptied, new requests queued behind them, health checks timed out and failed, and the autoscaler, reading those failures as a capacity problem, added instances that brought still more callers to a dependency that was already struggling. Nothing had crashed. The PSP was still answering, only slowly, and that slowness was enough to take down the service that depended on it.

A concert tour offers a fair picture of the same mechanism. If the local lighting crew simply fails to show up, the stage manager knows at once and can call in a backup crew. If they show up and work at a quarter of their usual pace, the stage manager waits, then the sound crew waits on the lighting rig, then the doors open late, and the whole evening backs up behind one slow team that never quite failed. The analogy breaks in one useful place: a stage manager can see the slow crew and decide to stop waiting. Software sees nothing unless someone has told it how long to wait and what to do afterwards, which is exactly the subject of Section 5.2.

Keeping a register

If integration points are where faith is required, a team ought at least to know where it is extending that faith. That sounds obvious, yet few teams could list every dependency of their own service from memory, and fewer still could say what the service does when each one misbehaves. Reviewing dependencies is an old part of launch practice at Google and Amazon, where a service is not considered ready until someone has walked through what it calls and how it copes. Encore’s version is an integration-point register, a table kept in each service’s catalog entry with one row per dependency. Each row records the timeout, the retry policy and the circuit breaker that guard the call; what the service does when the dependency is slow and when it is down; and the date on which the team last saw that behavior actually happen.

That last column is Encore’s own addition, and it is the one that matters. The other columns describe what the team intends; the date records whether anyone has checked the intention against reality. A fallback that has never been exercised is a belief about the system, and beliefs about failure behavior have a way of turning out wrong at the worst possible moment, as the AT&T engineers discovered about the code that ran only during recovery. A row with a recent date tells us that someone watched the dependency slow down, perhaps on a game day or in a real incident, and saw the service behave as the row says. A row with no date tells us we are still taking that behavior on faith.

The registers also show how much faith each service requires. For Orders & Payments the register runs to 11 rows, led by the two PSPs, because a checkout touches inventory, fraud signals, payment and the order store. For Seat Inventory, which was deliberately designed to depend on almost nothing, it runs to three. The difference is a design choice made visible: the service that must never sell a seat twice was built with as few places to extend trust as possible.

Writing the register for the first time is usually instructive, because it exposes dependencies that nobody chose. A typical example is a logging library that blocks the calling thread when its buffer fills. Nobody thinks of logging as an integration point, yet if the log shipper downstream slows, the buffer fills, every request that tries to write a log line waits, and a problem in the logging pipeline becomes an outage of the service itself. Such a dependency appears in no architecture diagram; it arrived with a library, and the register is often the first place it gets written down.

A register is never finished. Each release can add a dependency, change a timeout or alter a fallback, and so a register goes stale with every release unless the team revisits it, and the dates in its last column age even when nothing changes. The register’s real value is that it turns a vague unease about dependencies into a specific list of assumptions, each one either recently observed or not, and the next section takes up the mechanisms that those columns describe.

Recap. Integration points are the places where our system takes another system’s behavior on faith, and cascading failures travel along them from callee to caller, most often when a dependency slows rather than stops, because a slow call holds resources that a dead one releases at once. Components that are identical fail together, as the AT&T switches did. A register that records, for each dependency, when its failure behavior was last actually observed shows which of our assumptions have been checked and which we are still holding on faith.

Exercise 5.1. Write the integration-point register for one service you run, with a row for each dependency, including the ones nobody chose. For each row, fill in the date when you last saw the “slow” behavior actually happen, in a test or in production. How many rows have no date?

5.2 Timeouts, Retries, Circuit Breakers, and Backpressure

Timeouts derived from budgets

Section 5.1 showed a slow dependency holding threads, connections and queue slots for as long as we are willing to wait. The first defense is to decide how long that is. A timeout is a caller’s promise to itself about how long it will wait for an answer before it gives up and does something else. Every network call has one, whether or not anyone wrote it down, and that is the trouble: most production timeouts are library defaults that nobody chose, often measured in tens of seconds, set by a library author who knew nothing about our users. A default of that kind is not a decision. It is the absence of one, and Encore’s first big outage showed what it costs when a PSP that normally answers in 200 ms starts taking 8 s.

The discipline is to derive each timeout from the user’s patience rather than from the library. We start with a latency budget: the time the user-facing operation may take end to end, divided among the calls that serve it. Each hop receives a share, and its timeout must fit inside that share. Figure 5.2 shows the division for Encore’s 3 s checkout, from the moment the fan presses “pay” to the moment the confirmation comes back.

Hop Budget share Timeout Retries in path Normal p99
Edge and gateway 150 ms n/a none 40 ms
Orders: confirm hold with Seat Inventory 300 ms 250 ms one, if budget remains 60 ms
Orders: fraud signal from Bot Screening 200 ms 150 ms none; fail open with a flag 70 ms
Orders: charge via PSP 800 ms 800 ms none in path; reconciled later 450 ms
Orders: write order, emit OrderPlaced 250 ms 200 ms one 50 ms
Margin for queuing and the fan’s network 1,300 ms      

Figure 5.2 — The 3 s checkout budget, divided. Each timeout sits well above the dependency’s normal tail and within its share of the budget. The large margin is deliberate: on an on-sale morning, queues are where the time goes.

Read the table one row at a time and each line is a small argument. Confirming the seat hold normally takes 60 ms at the 99th percentile, so a 250 ms timeout leaves room for a bad moment without letting a sick Seat Inventory eat the whole checkout; the single retry is allowed only “if budget remains”, meaning only if the request’s overall deadline still leaves room for another attempt after the first has failed. The fraud signal from Bot Screening is useful but not essential at this point, because the fan has already passed screening at the Gate; if it does not arrive in 150 ms, Orders proceeds without it and marks the order accordingly, which is what “fail open with a flag” means. The PSP gets the largest share, 800 ms, because charging a card is the slowest and most important thing in the path, and it gets no retry at all, for reasons we come to shortly. The last row may look like waste. It is the most deliberate number in the table, because on an on-sale morning the time goes into queues, and a budget that spends everything on the happy path has nothing left when the queues grow.

That still leaves the question of where, exactly, inside its share, each timeout should sit. Marc Brooker’s advice, drawn from Amazon’s practice, is to begin with the rate of false timeouts we are willing to tolerate, meaning calls to a healthy dependency that we abandon only because they were a little slower than usual, and to read the timeout off the matching percentile of the dependency’s latency. If we can accept one false timeout in a thousand calls, the timeout belongs near the p99.9. The arithmetic is unforgiving in the other direction: a timeout set just above p99 abandons one healthy call in a hundred by design, and at Encore’s on-sale volumes one in a hundred is a great many fans. Encore’s timeouts therefore sit near each dependency’s p99.9, which is why every value in Figure 5.2 stands well above the normal p99 beside it.

A table like Figure 5.2 is only a plan, and three practices are needed to make the services behave as the plan says. The first is deadline propagation: instead of telling a callee “you have 250 ms”, the caller sends the absolute time by which it needs an answer, and each callee works only while that moment still lies ahead. The difference matters because time already spent upstream is gone; a service that receives a request with 40 ms left should not begin work that takes 200 ms. Encore’s gRPC calls carry deadlines, and each service passes its deadline on to the calls it makes in turn, just as distributed tracing asks services to pass on trace context. The second practice is the twin of the first, cancellation propagation: when a caller gives up, the cancellation travels down the chain, and the callees stop working on an answer nobody will read. Without it, a timed-out request keeps consuming capacity all the way down, which is exactly the hidden load a struggling system can least afford.

The third practice is a matter of honesty about what a timeout tells us. When a call that has a side effect times out, its outcome is unknown, and it stays unknown until someone reconciles it. A timeout means only that the answer did not arrive in time; it does not mean the work was not done. A PSP charge that timed out may well have succeeded on the provider’s side, and a naive retry could charge the fan twice. So Orders never retries a PSP charge inside the fan’s request. It reconciles the charge later, asking the provider what happened under the same idempotency key, and only then decides whether the purchase stands. I suspect that this distinction, between “failed” and “did not hear back”, is the single most commonly forgotten idea in distributed systems, and the one that most often costs real money.

Retries with jitter and a budget

A timeout tells us when to stop waiting; the next question is whether to try again. A retry is a bet that the failure was transient: a dropped packet, a brief pause, a replica restarting. Placed by one client, it is usually a good bet. Placed by every client at once, it becomes a denial-of-service attack on our own dependency, and the reason is synchronization. Clients that fail at the same moment, because the same dependency hiccupped under all of them, and then back off by the same exponential schedule, will also retry at the same moments, in waves. Each wave arrives just as the dependency is trying to recover, and knocks it down again.

The cure is jitter: randomness added to the wait before each retry, so that clients which failed together do not return together. Jitter turns synchronized waves into a steady trickle that a recovering dependency can absorb. Brooker’s simulations compared several schemes and found that “full jitter”, in which each client waits a random time between zero and the current exponential ceiling, did markedly better than exponential backoff alone. It is a slightly counterintuitive result, since full jitter sometimes retries almost immediately, but spreading the load evenly matters more than making any one client patient.

Jitter shapes when retries arrive; it does nothing to limit how many there are. That is the job of a retry budget, which caps retries as a share of ordinary traffic. Encore’s service mesh allows retries of about 10% of ordinary requests to each destination. It enforces this with a token bucket: each successful request adds a fraction of a token, each retry spends one, and when the bucket is empty, failures are returned to the caller instead of retried. The effect is that retries flow freely when failures are rare and dry up when failures are common, which is exactly when retrying stops being a good bet. The 10% figure is Google’s ratio, and it is tighter than the 20% that Envoy and Linkerd ship by default.

The budget has two companions. Retries happen at one layer only, the one immediately above the failing call, and only for idempotent operations, those that can safely be performed twice. The first rule matters because layers multiply, as Figure 5.3 shows. Suppose a request passes through three services before reaching a failing dependency, and each layer makes up to four attempts, one original and three retries. The bottom layer makes four calls for every request it receives, the middle layer calls the bottom four times, and the top calls the middle four times, so one fan’s click can become 4 × 4 × 4, or 64, calls on the dependency, arriving just when it is weakest. The second rule matters because retrying a non-idempotent operation, such as the PSP charge above, turns a transient fault into a duplicate effect.

Retries multiply across layers Load on a struggling dependency, as a multiple of normal, against the share of its calls that fail. One layer retrying three times can at most quadruple the load; three such layers stacked can multiply it 64 times as failure approaches 100%; a 10% retry budget caps it at 1.1 times. 0% 25% 50% 75% 100% 1× 2× 4× 16× 64× SHARE OF CALLS TO THE DEPENDENCY THAT FAIL LOAD ON THE DEPENDENCY (× NORMAL, LOG) 3 LAYERS × 3 RETRIES: 64× 1 LAYER × 3 RETRIES: 4× 10% RETRY BUDGET: 1.1× Three layers, three retries each One layer, three retries One layer, 10% budget

Figure 5.3 — Load on a failing dependency when every layer above it retries. Three layers of three retries can multiply it 64 times just as the dependency is weakest, while a 10% budget holds it near normal.

A retry budget, however, leaves one gap. It limits retries, but not first attempts, and first attempts sent to a backend that will only reject them still spend its capacity: the backend must accept the connection, parse the request and decide to refuse it, and under heavy overload the refusing alone can saturate it. The SRE book describes Google’s answer to this gap, client-side adaptive throttling. Each client keeps two counts over the last two minutes: how many requests it sent, and how many the backend accepted. While the backend accepts nearly everything, the client does nothing. Once requests exceed a small multiple of accepts, the client begins rejecting a growing share of new requests itself, before they ever leave, so the backend never has to spend effort turning them away.

# Google SRE book, ch. 21. Counts cover a rolling two minutes.
def reject_probability(requests: int, accepts: int, k: float = 2.0) -> float:
    return max(0.0, (requests - k * accepts) / (requests + 1))

if random.random() < reject_probability(window.requests, window.accepts):
    return fail_locally(request)   # never reaches the backend

The formula rewards a moment’s study. With k set to 2, a healthy backend that accepts nearly all of its requests gives requests - 2 * accepts well below zero, so the probability is zero and nothing is throttled. As the backend begins rejecting, accepts fall behind requests, and once requests pass twice the accepts the client starts dropping its own traffic. The system then settles where the backend receives about twice what it can accept: enough extra that the client notices quickly when the backend recovers, but not so much that rejections become the backend’s main workload. Each client reaches this decision alone, from its own counts, with no coordination at all, which is what makes the scheme robust.

There is one retry layer that no mesh can see, and it is made of people and their devices. Fans who see an error refresh the page, and the fan app may retry on their behalf before they even notice. Neither passes through the mesh’s budget, and so neither is limited by it. Section 5.5 shows Encore discovering exactly this layer during a game day.

Circuit breakers as state machines

Retries and budgets make each call more careful. A circuit breaker takes a broader view: it watches the calls to one dependency together, and when enough of them fail, it stops sending calls at all for a while, so the dependency can recover and the caller stops wasting threads waiting on it. The name comes from the breaker in a household electrical panel, which trips when a circuit draws too much current, sacrificing the circuit’s service to save the wiring from fire. The analogy holds well for the tripping. It breaks at the reset: a household breaker waits for a person to flip it back, while a software breaker tests the dependency for itself and closes again on its own.

That behavior is a small state machine. In the closed state, calls flow normally and the breaker counts failures. When failures cross a threshold, it moves to open and rejects calls immediately, without trying the dependency. After a while it moves to half-open and lets a few trial calls, called probes, through; if they succeed it closes, and if they fail it opens again. Those three states are familiar to most engineers. What is less familiar is that the states are the easy part, and that the parameters around them decide whether the breaker protects the system or harms it. Figure 5.4 lists those parameters, in the terms of Resilience4j, a common Java library.

Where the breaker lives also matters. A service mesh offers something it calls a “circuit breaker”, but it is usually a concurrency limit combined with outlier ejection, which removes individual misbehaving instances from a load-balancing pool. That is useful, but it is not a breaker that understands payments, can count a slow call as a failure, or knows to switch providers. Encore’s PSP breaker therefore lives in the payment client inside Orders, close to the code that knows what a payment is.

Parameter Encore’s PSP breaker Failure if set badly
Rolling window 10 s too long reacts slowly; too short flaps
Minimum volume before tripping 50 calls too low trips on two unlucky calls
Failure rate that opens it (timeouts count) 40% too low opens on normal noise
Slow-call threshold 600 ms, for 50% of calls at or above the 800 ms timeout, it never fires
Open duration 5 s, growing to 60 s too short hammers a sick dependency
Half-open probes 5, all must succeed too many re-trigger the overload
Scope per PSP endpoint, per region one global breaker makes a regional fault total

Figure 5.4 — The circuit breaker’s tuning surface. The slow-call threshold must sit above the call’s normal p99 and below its timeout, here 450 ms, 600 ms and 800 ms, or a PSP that is slow without failing outright never trips it.

The row most worth dwelling on is the slow-call threshold, because it is where a breaker most often disagrees with the timeouts around it. Encore’s first big outage was a slow PSP, not a failed one, and a breaker that counts only errors would barely have noticed it. So the breaker also counts a call as slow when it takes longer than 600 ms, and opens when half the calls in its window are slow. The number is constrained from both sides. It must sit above the PSP’s normal p99 of 450 ms, or an ordinary busy minute would trip it. And it must sit below the 800 ms timeout, because a call that would take longer than 800 ms is cut off by the timeout and recorded as a failure, never as slow; a threshold at or above the timeout can therefore never fire. The three numbers, 450, 600 and 800, have to be read together, and a team that tunes them separately, in different files owned by different people, will sooner or later set one that silently cancels another.

Two of Encore’s other choices deserve a word. Requiring all five half-open probes to succeed is stricter than Resilience4j’s default, which closes the breaker once the probes’ failure rate falls below the threshold. Encore chose strictness because a PSP that flickers between healthy and sick is costly: every attempt sent to it while it is failing may become an unknown charge that must be reconciled, while a few extra seconds on the secondary provider cost almost nothing. The second choice is about scope, and here Brooker offers a warning: a breaker scoped more widely than the failure it guards can harm a sharded design. If one shard of a sharded service falls sick, a single breaker in front of the whole service sees a rising failure rate and opens for every key, including the healthy shards that could have served most of the traffic. That is why Seat Inventory, sharded by event, has no breaker at all. Encore’s calls to it rely on deadlines and the retry budget instead, which fail individual requests without cutting off the healthy shards.

A breaker that opens must send the caller somewhere, or it merely produces errors faster. The fallback is the other half of the design, and for payments Encore’s is a ladder of degraded modes, each rung a smaller promise than the one above it. On the first rung, the breaker on the primary PSP opens and moves new payment attempts to the secondary provider. Attempts already in flight finish or fail where they started, because idempotency keys belong to one provider, and a charge half made at one cannot be completed at the other. On the second rung, reached if both providers are degraded, verified fans’ seats are held as a pending payment: the hold runs for up to 20 minutes instead of the usual 5, with a cap on how many seats each fan may hold this way. When a provider recovers, the fan is sent a link to complete the payment, with strong customer authentication. Holds left unpaid lapse, and those seats return to sale. On the last rung, checkout fails fast with an honest message, and the Gate slows admission so fewer fans arrive at a checkout that cannot serve them.

What no rung does is issue a ticket without an authorized payment. That is partly law, since European rules require the fan to authenticate a card payment as it happens, and partly design, since Encore holds no card data and so could not charge a card later even if it wished to. A tour manager whose headline act falls ill may shorten the show, switch to an acoustic set or reschedule the date, but does not let the audience believe the band is about to come on. A degraded mode may shrink what we promise; it may never make the promise false.

A ladder of fallbacks carries its own danger, which Jacob Gabrielson describes from Amazon’s experience: a fallback that runs only in emergencies tends to fail exactly when it is needed. It is code that almost never runs, against a provider that has seen almost none of our traffic, and both drift silently between emergencies. Encore’s answer is to keep the secondary warm. Orders sends a small, steady share of ordinary payments through the secondary PSP every day, so the integration is exercised, its credentials are valid and its latency is known before the day anyone depends on it. The same doubt applies to the breaker itself. A breaker that has not opened in a quarter is most likely guarding a healthy dependency, which is good news, but it has not been seen to work either, and only fault injection, the subject of Section 5.5, can show that it does.

Backpressure

Everything so far has been about the caller protecting itself from a callee. Backpressure runs the other way, letting the callee protect itself. Backpressure is the means by which a component that cannot keep up tells its upstream to slow down, before it accepts work it cannot finish. The image is borrowed from plumbing, where a narrow pipe pushes back against the flow feeding it, and the image is apt in one respect: the pressure is felt upstream, where something can still be done about it. In software, three habits make it work. Queues are bounded, so that a full queue refuses new work instead of growing until every item in it is too old to matter. Callers honor a “retry after” signal, waiting as long as the busy service asks instead of hammering it at once. And failure comes early, at the first point that knows the work cannot be done in time, rather than late, after every layer has spent effort on it.

Backpressure has to end somewhere, because each service that slows down pushes the pressure onto the one before it, and eventually the pressure reaches a person. At Encore the chain ends at the Sale Gate, the one place in the system where fans are meant to wait. There, a waiting fan sees a queue position on a static page, which is a far kinder experience than an error from deep inside checkout. Section 5.3 takes up the Gate as an admission controller and what to do when, despite it, too much work gets in.

Recap. Timeouts come from the user’s budget, not from library defaults, and they travel down the call chain as deadlines, with cancellations following them; a timed-out side effect is unknown until it is reconciled. Retries need jitter to break up synchronized waves and a budget to limit their volume, they belong at a single layer, and clients can throttle their own first attempts when a backend is rejecting most of them. Breakers must agree with the timeouts around them, and their fallbacks are ladders of smaller but honest promises, each exercised a little every day so we know it works. Backpressure carries overload back upstream to the one place, the Sale Gate, where waiting is part of the design.

Exercise 5.2. Build Figures 5.2 and 5.4 for one operation you run. Does any slow-call threshold sit at or above its timeout, and which of your fallbacks ran in production last week?

5.3 Overload, Load Shedding, and Tail Latency

Admission control at the Gate

Backpressure, as the previous section left it, pushes the signal to slow down all the way upstream until it reaches someone who can wait. Sooner or later, though, the signal arrives at the edge of the system, where the work comes from people rather than from other services, and something there must decide how much of it to accept. Two ideas govern that decision, and they are easy to confuse. Admission control decides at the entrance how much work to let in at all. Load shedding discards work that is already inside the system but cannot be finished in time. The first is prevention and the second is triage, and triage is always the more expensive of the two, because the work it throws away has already consumed capacity: a request shed halfway through checkout has already been parsed, authenticated, routed and partly processed, and every one of those steps was paid for and then wasted.

A concert venue makes the difference concrete. The doors open at a set time, staff scan tickets at a steady pace, and the crowd that has not yet been let in waits outside, where waiting is cheap and nothing inside is harmed by it. That is admission control. If instead the doors were thrown open and the venue later discovered that the hall was dangerously full, someone would have to walk people back out through a crowd that had already found its place, which is slower, angrier and more dangerous for everyone. That is load shedding. Here the picture stops matching software, and the mismatch is instructive: a venue’s capacity is printed on a certificate and stays put, while a software system’s capacity moves with every release, every cold cache and every slow dependency, and so the number at the door is always an estimate.

The Sale Gate is Encore’s admission controller, its doorkeeper. It admits about 1,200 fans per second per event, a rate chosen to keep Seat Inventory below 80% of its measured capacity, and everyone else waits on a static page that shows them their position in the queue. A static page costs almost nothing to serve, so a great many fans can wait there without putting any weight on the services behind it. The visible queue position matters too, because a fan who can see the line moving has less reason to refresh in frustration and add load of their own. Commercial waiting rooms from Cloudflare, Queue-it and AWS work the same way: an operator sets the admission rate, and the product holds everyone beyond it in a queue.

That operator-set rate is the weak point, and it deserves to be named as such. The rate is a judgment, reviewed at the on-sale readiness review the Wednesday before each big on-sale, and it is only as good as the load test behind it. A test that misjudges capacity produces a rate that misjudges it too, and the Gate will then faithfully admit exactly the wrong number of fans. The natural wish is to let the system set its own rate by watching how its services are coping, and one level down that is already proven practice. Netflix’s concurrency-limits library and Envoy’s adaptive concurrency filter both bound how much work a single server has in flight by the latency that server observes: when responses slow, the limit shrinks, and when they speed up, it grows again, in the spirit of the congestion control by which TCP probes for the capacity of a network path. Encore’s services run the Envoy filter. A waiting room steered by the latency of a service several hops downstream is younger practice, with a longer and more delicate feedback loop, and so the Gate’s rate stays a human judgment for now. This seems to me the right order of things: automate a control loop where it has been proven, and keep a person on the one whose mistake would turn away an entire on-sale.

Shedding behind the gate

A well-chosen admission rate does not make the services behind the Gate safe, because the Gate controls how many fans arrive, not how much work each one causes. Retries can multiply that work, a cold cache can make each request several times more expensive than the load test assumed, and a slow dependency can hold threads and connections long enough that a normal arrival rate becomes an overload. So the services behind the Gate need a way to shed, and shedding well means deciding in advance which work matters most. Encore’s services tag each request with a criticality class, a label saying how much the business loses if that request is dropped, following the practice the SRE book describes. There are three classes: checkout, for a fan who is paying for seats; browse, for a fan looking at seat maps and prices; and background, for work nobody is waiting on at that moment. Under pressure they are shed in reverse order, background first and checkout last. This is triage in the medical sense, where a crowded emergency department sees the patient whose condition is most urgent rather than the one who arrived first, and like medical triage it works only if the categories were agreed before the crowd came through the door.

Three further rules decide how the shedding is done, and each follows from the cost of wasted work. The first rule is to shed early, before expensive work is spent on a request that will be discarded anyway. A request rejected at the front door of a service costs almost nothing; one abandoned after its database query has already cost the query.

The second rule is to measure pressure by time in queue rather than by the length of the queue. This is the insight of Kathleen Nichols and Van Jacobson’s controlled-delay algorithm, CoDel, devised for network routers in 2012, which Facebook later carried into its RPC servers. The reasoning is that a queue’s length says little on its own: a queue of a hundred cheap requests drains in moments, while a queue of ten expensive ones may not. How long requests have been waiting is the quantity that matters, because every request has a deadline, and a request served after its caller has given up wastes capacity twice: once in doing work nobody will read, and again because that capacity was taken from a request that could still have succeeded.

The third rule applies under severe overload, when the queue is already long and the oldest requests in it are probably past saving. There Facebook’s servers serve the newest requests first, last in, first out, because the callers of new requests are still listening, while the callers at the back of an old queue have very likely given up. This feels wrong, and the feeling is worth examining. Each of these policies deliberately trades fairness for goodput, the rate of work completed usefully within its deadline, as distinct from throughput, which counts every response, including the ones nobody waited for. Under last in, first out, the fan who has waited longest is the one least likely to be served, which is unfair by any everyday standard and right by the standard of how many fans finish buying their tickets. That trade-off should be written down where the on-call engineer can find it, because during an incident a policy nobody explained will look exactly like a bug.

Metastable failures

Admission control and shedding both assume that once load falls, the system recovers. The most dangerous overloads are the ones in which that assumption fails. The Architecture book borrowed a term for them from Nathan Bronson and colleagues (2021): a metastable failure is one that persists after its trigger has been removed, because the system’s own response to the failure keeps it failed. The word comes from physics, where a metastable state holds steady until a small push sends it somewhere it cannot easily climb back from. Bronson and colleagues describe three ingredients. There is a vulnerable state, typically a system running efficiently close to its capacity, which is precisely the state that careful cost management encourages. There is a trigger, such as a slow dependency or a burst of traffic. And there is a sustaining effect, a feedback loop that keeps the system down after the trigger has passed. These failures are not exotic. Lexiang Huang and colleagues found them at 11 organizations, including at least four of 15 major AWS outages, and retries were the commonest sustaining effect: requests time out, clients retry, the retries add load, more requests time out, and the loop feeds itself.

AT&T’s collapse, which opened this chapter, had the same shape. The trigger, one switch’s minor fault, was over in seconds, and yet the network stayed failed for hours. Its sustaining effect, though, was not excess ordinary traffic but the recovery protocol itself, each switch’s announcement resetting its neighbors, which is why the cure needed a rollback to the previous software as well as less signaling load. Encore’s PSP outage had the classic structure. The trigger was the PSP slowing from 200 ms to 8 s. The sustaining effects were retries, which multiplied the load on a provider that could not answer, and an eager autoscaler, which responded to failing health checks by adding instances that opened still more connections to the same struggling dependency.

The practical lesson is uncomfortable. A metastable system will not recover when the trigger is fixed, and often not even when new capacity arrives, because new capacity starts cold, with empty caches and no warm connections, and the loop simply absorbs it too. The system recovers only when load falls below the level at which the loop can no longer sustain itself, and that level may lie well below normal. In practice that means shedding far more than feels reasonable, turning retries off, and then readmitting traffic in steps while watching that each step holds. A fire crew facing a fire that keeps relighting works the same way: it does not stop when the visible flames are gone but cools everything well below the point of ignition, and only then lets the building be used again. The analogy breaks because nobody resents firefighters for using too much water, while an engineer who turns away 70% of the fans during an on-sale will be asked to explain it afterward. In a metastable failure the cure always looks like an overreaction, and so the runbook should say so in advance, plainly and with numbers, since nobody at 3 a.m. wants to be the person who turned away 70% of the traffic on purpose and on their own authority.

Better still is to find the loop before it finds us. Encore’s load tests push Seat Inventory past the point where goodput stops rising, deliberately into overload, then bring the load back down to normal and check, as the SRE book advises, that the service recovers unaided. A service that returns to health when the load drops has no sustaining loop at that level. One that stays degraded at normal load has just shown us a metastable failure in a rehearsal, where it costs an afternoon rather than an on-sale.

Tail latency under load

Overload rarely announces itself in the average. It shows first in the tail, the slowest few percent of requests, because those are the requests that land behind a long queue or on a busy replica. One technique aimed squarely at the tail is the hedged request, from Dean and Barroso’s “The Tail at Scale” (2013): when a read has not returned within some threshold, the client sends a second copy to another replica and uses whichever answer comes back first. Hedging cuts the tail because a slow replica is usually slow for reasons of its own, so the second copy rarely meets the same delay. But hedging has a cost that grows at the worst moment. During overload, many requests cross the threshold, so many are hedged, and the system receives extra load exactly when it can least absorb it, which is the retry storm again in a politer form.

Encore therefore hedges narrowly, and each restriction answers one of these dangers. It hedges only idempotent reads of seat-map geometry, the layout of sections and rows, so a duplicate request can never cause a duplicate effect. It hedges only reads that have taken longer than the p95, so in normal operation only about one read in 20 is even a candidate. It allows hedges only within a budget of about 5% extra requests, so that when the system is busiest and many reads are slow, the budget runs out and hedging stops instead of adding to the overload. And it cancels whichever copy loses, so the replica still working on the slower copy stops spending capacity on an answer nobody will read.

Recap. Admission control at the entrance is cheaper than shedding inside, because shed work has already been paid for, and the Gate’s admission rate is a human judgment that must keep being reviewed against honest load tests. Behind the Gate we shed by criticality and by time in queue, accepting that these policies trade fairness for goodput and writing that trade-off down. Metastable failures are common and outlast their triggers; ending one takes more shedding than feels reasonable, and a load test that pushes past the peak and then checks for recovery finds them before an on-sale does. Even a technique that helps the tail, such as hedging, needs a budget, or it becomes one more source of overload.

Exercise 5.3. Find an incident in a system you know where load stayed high, or the service stayed degraded, after the original cause was fixed. What was the sustaining effect, and what runbook text, written in advance, would have given the on-call engineer the confidence to shed enough traffic to break the loop?

5.4 Cells, Regions, and Blast Radius

A ladder of bulkheads

The patterns of the last two sections act on a failure while it is happening: a timeout cuts a slow call short, a breaker stops calling a sick dependency, the Gate turns fans away before Seat Inventory drowns. This section asks a different and more architectural question, which is how far a failure can travel before something stops it. The blast radius of a failure is the set of users, tenants or functions it can affect. We cannot make failures rare enough to ignore, but we can decide, in advance and on purpose, how large each one is allowed to become.

The Architecture book used a ship’s bulkheads as the image for shrinking the blast radius: watertight walls that let a holed ship flood one compartment and stay afloat. Operations adds a refinement that the image hides. Bulkheads come in sizes, and each size contains a different class of failure. A wall around one connection pool keeps a slow dependency from starving the rest of a process, but it does nothing when the process itself crashes; for that we need a wall around the process. Each larger wall exists because the smaller one has a known gap. Figure 5.5 arranges these walls as a ladder, from the smallest compartment to the largest.

Boundary Contains Does not contain At Encore
Thread or connection pool one slow dependency a crash of the process a separate PSP pool in Orders
Instance or pod a crash, a memory leak a fault every pod shares pods spread across zones
Shard a hot or failed partition a defect every shard runs four shards per large event
Cell a poison tenant; a bad deploy, reaching cells in turn the shared router and control plane Professional cells; self-service cells of ~50
Availability zone a power or network fault; a bad deploy staged by zone a regional dependency every tier across three zones
Region a regional outage; a bad deploy staged by region a global control plane; a latent defect already everywhere two EU regions; event writes pinned to one

Figure 5.5 — The ladder of bulkheads. The “does not contain” column of each row is the reason the next row exists.

Figure 5.5 is best climbed one rung at a time, with the third column in view. Encore gives the PSP its own connection pool in Orders, so a slow PSP cannot take every connection the service has, which was exactly the mechanism of Encore’s first outage. But a pool cannot protect against a process that dies, so pods are spread across zones. Pods cannot protect against a fault they all share, so data is split into shards, four for each large event. And so on up the ladder, until we reach the region, whose own gaps (a global control plane, a defect already present everywhere) have no larger wall above them. Choosing a rung, then, is really choosing which failure we fear most and paying for the smallest wall that holds it.

One class of failure deserves particular attention, because it is the one we cause ourselves: the bad deploy. Here the ladder behaves in a way that is easy to miss. A rung contains a bad deploy only if the change reaches that rung at a different time from its neighbors. A wall that every compartment crosses at the same moment is no wall at all. This is why Amazon deploys to one box, then one zone, then region by region, and why Microsoft rolls Azure changes through canary regions first: in each case the rollout itself is staged along the bulkheads, so that a defect shows itself in one compartment while the others are still running the old code. Among these rungs, the cell is the smallest at which a whole application, with all its services, can be updated on its own; pods and shards are pieces of one service and usually take its new version together, whereas a cell is a complete copy that can be held back while another moves ahead.

Staging has a limit, though, and it is the same limit this chapter opened with. No rung contains a latent defect that is already everywhere when its trigger arrives. AT&T’s 114 switches had all been running the faulty recovery code for weeks; when the trigger came, every switch was equally ready to fail, and no boundary between them could help. Google Cloud relearned this on 12 June 2025 (Chapter 4). The new code in Service Control had been rolled out carefully, region by region. Its flawed path, however, did not run until a policy change arrived, and that policy change, replicated globally in seconds, reached every region at once. The code had been staged, but its trigger had not, so the staged rollout did not help. To my mind, this is the most important line in Figure 5.5: a bulkhead holds only against what crosses it at its own time, and data and configuration cross far faster than code.

Cells for tenants

Of all the rungs, the cell is the one an architect most deliberately draws, and it is the one Encore leans on for its software-as-a-service tenants. A cell is a complete, independent copy of the application serving a fixed slice of customers: a blast radius drawn on purpose. Where a shard divides one service’s data, a cell divides the whole system, with its own services, its own data and its own capacity, so that what goes wrong inside one cell has no path to the customers of another.

Encore’s Professional tenants live in Kubernetes cells, and about 500 self-service venues live in serverless cells of about 50 venues each. The arithmetic of that choice is what makes it worthwhile. Every deploy and configuration change reaches a canary cell of internal and early-adopting tenants first, then the remaining cells in the waves of Chapter 4. If a release carries a defect that the canary cell does not reveal, and it reaches the next wave, it meets one cell of about 50 venues before the wave pauses, so a defect that would have reached all 500 venues at once in a single pooled deployment reaches about 50. The same logic applies to a poison tenant, a customer whose data or traffic triggers a fault: in a pooled system it can harm everyone, and in a cell it can harm only its cellmates.

The concert world has understood this kind of independence for a long time. Big stadium tours carry more than one steel stage structure, leapfrogging them from city to city, so that a storm delaying one build does not cancel the next night’s show. Cells give Encore the same independence: trouble in one copy leaves the others free to go on. The analogy is worth pressing until it breaks, because the place it breaks is instructive. Two stages built from one faulty drawing will fail alike, however many trucks carry them apart, and cells running one faulty release fail alike too. Independence of copies protects against accidents that happen to one copy; it does nothing against a mistake in the design they share. That is why the staged rollout across cells matters as much as the cells themselves.

There is one more thing the cells share, and it is the most dangerous: the router that maps each tenant to its cell. Every request passes through it, so its failure crosses every bulkhead at once, and the ladder offers no wall above it. AWS’s guidance on cell-based architecture asks for this layer to be as thin as possible, doing little more than looking up a tenant and forwarding the request. Encore follows that advice, and goes a step further in discipline: the router is the component it changes least often of all those it owns. Here the usual virtue of frequent, small change gives way to a different calculation. A component whose failure is shared by every customer earns its stability by doing almost nothing, and by being touched almost never.

Shuffle sharding

Cells divide tenants between copies of the system, but inside a pooled cell, where 50 venues share the same workers, the question of isolation arises again on a smaller scale. One venue running a huge import, or receiving a flood of webhooks, can occupy workers its neighbors need. The obvious answer is to partition the workers and give each venue a fixed group, but a fixed group means that every venue in it shares the misfortune of its noisiest member. Shuffle sharding, which Colm MacCárthaigh described from AWS practice, takes a cleverer route: it gives each tenant a small random combination of workers instead of a fixed partition, so that no two tenants are likely to share all their workers.

In each self-service cell, Encore divides its import and webhook workers into eight lanes and assigns each venue two of them. Eight lanes can be paired in 28 different ways (eight choices for the first lane, seven for the second, halved because the order does not matter), so there are 28 possible pairs for the 50 venues of a cell. Figure 5.6 shows what happens when one venue’s runaway import floods its two lanes.

Shuffle sharding in a cell Eight worker lanes in one self-service cell, with each venue assigned two. Venue A's runaway import floods lanes 2 and 5. Venues B and C share one flooded lane each, and their consumers move the work to their other lane; D and E share none; F, by chance, holds the same pair and is hit. Any one neighbor has about a 1-in-28 chance of that, so in a cell of 50 one or two are hit. Venue A Venue B Venue C Venue D Venue E Venue F L1 L2 L3 L4 L5 L6 L7 L8 runaway import floods both work moves to L7 work moves to L1 untouched untouched same pair: hit Fixed partitions (four groups of two lanes): a runaway venue takes its whole group, about 12 of its 49 neighbors. Shuffled pairs (28): one or two share both lanes, if work can move. Noisy venue and its flooded lanes Neighbor venue Lane assigned to a venue

Figure 5.6 — Shuffle sharding across a self-service cell’s eight lanes. A runaway venue floods its own two lanes; neighbors sharing one of them keep working on the other, and in a cell of 50 one or two neighbors, on average, hold the same pair and are hit.

The runaway venue’s neighbors fall into three groups. Most hold neither of its lanes and never notice the flood. Some share one lane with it, and they keep working on their other lane. A few hold exactly the same pair, and they are flooded along with it. The isolation is cheap, since it needs no extra workers, only a different way of assigning them, but it is conditional, and the conditions are worth stating plainly.

The first condition is that work must be able to move. A neighbor that shares one flooded lane is protected only if its consumers take its work from the other lane while the first is clogged. If each piece of a venue’s work were bound to one particular lane, half of that venue’s work would wait behind the flood. MacCárthaigh’s account assumes that work can move, and Encore’s consumers are built so that it does.

The second condition is that pairs repeat. With 28 pairs and 49 neighbors, some neighbors must hold the same pair as the runaway venue. Any one neighbor shares the runaway’s exact pair about one time in 28; across 49 neighbors, that comes to 49 divided by 28, or about 1.75, which is to say that on average one or two neighbors are hit in full. Many more share a single lane: of the 28 pairs, 12 contain exactly one of the runaway’s two lanes, so on average about 21 neighbors run on one lane, at reduced capacity, until the flood clears. Encore spreads the repeats evenly when it assigns pairs, so that no pair is crowded, and accepts what remains. The comparison that justifies the scheme is with fixed partitions. Had Encore split its eight lanes into four fixed groups of two, each group would serve about 12 or 13 venues, and a runaway venue would take about 12 neighbors down with it, instead of one or two. The same eight lanes, assigned by combination rather than by partition, shrink the full blast radius by roughly a factor of six.

Static stability

Everything so far in this section has been about keeping a failure small. The last idea is about recovering from it, and in particular about what recovery is allowed to depend on. Most systems have two parts with very different jobs. The data plane does the work customers see: routing requests, selling seats, taking payments. The control plane changes the data plane: it creates instances, scales capacity, updates routing tables and elects new leaders. A system is statically stable when its data plane keeps working, unchanged, while its control plane is impaired, so that recovery never depends on creating, scaling or reconfiguring anything.

The idea is old, and engineers in other fields would recognize it at once; the name is AWS’s. Its central lesson is uncomfortable. The control plane is likeliest to be overwhelmed exactly when everyone needs it, because a zone or region failure sends every customer of the cloud to the same control plane at the same moment, each asking for new instances to replace the ones they lost. A recovery plan that begins “and then we launch more capacity” is a plan to queue behind everyone else at the worst possible time. A statically stable design avoids the queue by not needing to join it.

Encore applies the idea in three places. First, the tenant-to-cell routing table, which the router consults on every request, is cached on every edge node, with an alert when a node’s copy grows old; if the service that publishes the table fails, the edge keeps routing with what it already has. Second, each tier carries enough capacity across its three zones that losing one zone needs no scaling at all; the surviving two zones can already carry the load. Third, the seat ledger’s replicas in the other region, together with the witness, already hold every committed write, so a region failover elects a new leader among copies that are already running and builds nothing new, as Chapter 6 tests. In each case recovery is a matter of using what exists, not of creating what is missing.

The price is idle capacity: spare headroom in every zone, replicas that serve no writes until the day they must. That spare capacity can look like waste on a cost report, and in a quiet quarter it is hard to defend. In return, recovery uses only what is already running, and it does not depend on any system that might be failing at the same moment for the same reason. For a company whose busiest hour is a big on-sale that cannot be rescheduled, that is a trade worth making.

Recap. Bulkheads come in sizes, and we choose among them by the failure we fear most; each rung exists because the one below has a known gap. Any rung contains a bad deploy that reaches it at its own time, cells are the smallest rung at which a whole application can be staged, and no rung contains a defect already everywhere when its trigger arrives, because configuration and data often cross every wall at once. Shuffle sharding shrinks the blast radius inside a pooled cell cheaply, provided work can move between lanes, and static stability keeps recovery from depending on a control plane that is under stress at the very moment we need it.

Exercise 5.4. Draw Figure 5.5 for your system, with the third column filled in honestly. Which shared component (a router, an identity provider, a global configuration store) crosses every rung, and does its data reach production in stages as your code does?

5.5 Chaos Engineering and Game Days

The experimental attitude

Every pattern in this chapter rests on a claim about how the system behaves under conditions we hope never to see. The breaker will open when the PSP slows. The cell will contain a bad tenant. The failover will finish before fans notice. We can rarely check such claims in ordinary operation, because the conditions they describe rarely arrive, and so the claims quietly decay. A release changes a timeout, a library swaps its defaults, a runbook falls out of date, and nothing tells us, because nothing has tested the claim since the day it was written. Chaos engineering is the practice of testing those claims on purpose, by bringing the unwelcome conditions about ourselves, at a time and scale of our choosing, instead of waiting for them to arrive on their own.

The practice has a short and fairly well-recorded history. At Amazon in the early 2000s, Jesse Robbins, a volunteer firefighter as well as an engineer, ran exercises he called GameDays, which took real capacity out of service to see how both the systems and the people coped. The firefighter’s habit shows: a fire company does not wait for a fire to discover whether its hoses reach. At Netflix, during the company’s move onto AWS from around 2008, engineers took the idea further and made failure routine on purpose, so that every service had to survive the loss of its neighbors as an ordinary event; Chaos Monkey was the famous result. The community later wrote its approach down as the Principles of Chaos Engineering, which define the practice as “the discipline of experimenting on a system in order to build confidence in the system’s capability to withstand turbulent conditions in production.” The principles ask for five things: a hypothesis about the system’s steady state, injected events that resemble real-world ones, experiments run in production, automation so the experiments can run continuously, and a minimized blast radius. The practice is now widely adopted, but we should be honest about the evidence: the case that it improves outcomes still rests mostly on practitioners’ reports. Those practitioners do agree on one precondition. Experiments belong in production only once observability, automatic aborts and an on-call rotation are in place to catch the problems the experiments expose. An experiment that breaks something nobody can see, and that nothing can stop, is simply an outage we caused.

The word in that definition that matters most is experiment, and it is worth being precise about how an experiment differs from a test. A test checks a property we already know the system should have, and it passes or fails. An experiment asks a question whose answer we do not know, and its result teaches us something either way. “Does the breaker open when the PSP is slow?” is a test: Section 5.2 specified the answer, and we are checking that the code agrees. “What happens to checkout when the PSP is slow during a shard failover?” is an experiment. Each failure has been studied alone, but nobody has designed for the two together, and the interesting behavior, if there is any, lives in their interaction. I have come to believe that this is where most of chaos engineering’s value lies. Our designs handle the failures we imagined one at a time; production delivers them in combinations.

Game days

Automated experiments test the machines. But Lisanne Bainbridge’s ironies of automation, which the Operations book takes up in its third chapter, warn us that the people who must step in when the automation fails are part of the system too, and their skills decay faster than the code does. A game day addresses that half of the problem. It is a scheduled exercise in which people and systems face an injected failure together, with observers recording what the people did as carefully as what the machines did: who was paged, which dashboard they opened first, where the runbook helped and where it misled them. Two published programs make good models. Google’s annual Disaster Recovery Testing (DiRT), which Kripa Krishnan described in 2012, and Slack’s Disasterpiece Theater share the habit that makes a game day worth its cost: each finding is followed until it is fixed, not merely written down.

Encore calls its quarterly game days tech rehearsals, after the theater’s practice of running every light, sound and scene change in sequence before opening night, so that the crew discovers the cue that does not work while there is still no audience in the seats. The analogy holds well in one respect: a rehearsal tests the crew and the equipment together, and it is the crew’s timing as much as the equipment that it exposes. It breaks in another. Once a show opens, its cues are largely fixed, and a good tech rehearsal stays true for the whole run. A production system changes with every release, so a rehearsal proves only that the system and its people worked on the day of the rehearsal. That is why Encore runs them every quarter instead of once, and why each one is designed around something that has changed since the last.

The tech rehearsal

Last quarter’s rehearsal is a good example of the form. It combined two failures that Encore had drilled only separately: a slow primary PSP, and a failover of one seat-ledger shard. It also served as the quarter’s evidence that the PSP breaker actually opens, the evidence Section 5.2 said only fault injection could supply. It ran in production on a Tuesday morning, a deliberately quiet time, against the hidden test event that the synthetic buyers use. For the occasion the test event was given four seat-ledger shards of its own, so that failing over one of them touched no real event’s seats. The experiment was written down in advance:

experiment: psp-latency-during-shard-failover
hypothesis: >
  Synthetic checkout success stays at or above 97% within the 3 s budget;
  the primary PSP breaker opens within 15 s; new payments move to the secondary;
  shard 2 failover rejects writes for under 60 s; no seat is sold twice.
target: test event only (tenant: encore-internal), home region
injections:
  - at: T+0     psp_latency: { psp: primary, added: 2s, share: 60% } # mesh fault
  - at: T+5m    shard_failover: { event: test, shard: 2 } # runbook step, by hand
abort_if:
  - real-event checkout SLO burn rate > 2x for 5m
  - any duplicate SeatSold for the test event
duration: 30m

Each part of that file does a job. The hypothesis is phrased in terms a fan or the finance team would recognize (checkouts succeed, payments move, no seat is sold twice), not in terms of internal metrics, because the point is to learn whether the experience survives. The injections are staggered: the PSP slowdown starts first and is injected by the service mesh, and five minutes later, once the breaker should already have done its work, an engineer fails over shard 2 by hand from the runbook, exactly as it would happen in a real incident. The abort conditions mark the edges of the blast radius. If real fans’ checkout starts burning its error budget at more than twice the sustainable rate for five minutes, or if a single seat in the test event is sold twice, the experiment stops at once, whatever it has or has not yet taught.

The machines did what the hypothesis predicted, and in some respects did better. Adding 2 s to 60% of PSP calls pushed those calls past their 800 ms timeout, so they counted as failures, and the breaker opened in 9 s, well inside its 15 s target. New payment attempts moved to the secondary PSP. The attempts that had timed out on the primary were, as Section 5.2 explained, of unknown outcome, since a charge might have gone through after the caller stopped waiting; reconciliation settled the last of them within four minutes of the injection ending. Because the secondary carried the load, no hold had to fall back to a pending payment. On the ledger side, the fenced failover of shard 2, in which the old leader’s term is fenced off so that it can no longer write once a new leader is chosen, rejected writes for 38 s against a target of under 60 s, and no seat was sold twice.

The people’s side of the rehearsal told a different story, and its two findings were the reason the morning was worth having. The first concerned the failover itself. Jonas, the Seat Inventory engineer who performed it, had never failed over a shard by hand, because the automation had always done it for him. The runbook he followed named a flag that had been removed two releases earlier, so the step took 11 minutes instead of 3. This is precisely the deskilling Bainbridge warned of: the automation had worked so reliably that the manual path, and the knowledge needed to walk it, had decayed without anyone noticing. The second finding was in the fan app. When the failover rejected holds, the app retried each rejected hold three times at fixed one-second intervals. That retry layer sat outside the service mesh, so the mesh’s retry budget never saw it, and its fixed intervals meant that clients rejected together retried together, in synchronized waves. Section 5.2 had argued for retries at one layer only, with jitter, and the app had quietly broken both rules. The app team added jitter and the client-side adaptive throttle described in Section 5.2.

One more line in the observers’ log deserves recording, though it seemed minor at the time. While the synthetic buyers were retrying their rejected holds, Bot Screening’s velocity rule, which looks for clients acting faster than people do, quarantined several of them. The log marked this as expected, since synthetic traffic does look synthetic, and the item was closed. Nobody asked the next question: what the same rule would make of a large crowd of real fans, frustrated by rejected holds, retrying in the same way.

That closing entry shows both the value of a game day and its limit. A game day finds out, cheaply and on a quiet morning, which of our resilience claims have never really been tested, and its observers will usually write down more than the organization is ready to act on. Whether a finding is fixed or merely closed is a choice the organization makes afterward, and so the Reliability team reports each quarter not only how many findings each rehearsal produced, but how many were fixed and how many were merely closed.

Recap. Chaos engineering treats each resilience claim as a hypothesis and tests it with a deliberate experiment, run in production within a bounded blast radius, but only once the means to observe the experiment and abort it are in place. Its richest questions concern failures in combination, which designs rarely anticipate. Game days add the people to the experiment, and they often show that the human side of recovery, the hand steps and the runbooks, has decayed faster than the automation that usually spares us from needing it.

Exercise 5.5. Design a game day that combines two failures you have so far drilled only separately. Write a hypothesis a user would recognize, set abort conditions that bound the blast radius, and name the human step you suspect nobody has practiced recently. Then decide who will follow each finding until it is fixed.

Kata: Kick-Off

Your brief: “Matchday.” Matchday is a sports-streaming service operating in five EU countries, built and run by 40 engineers. On a peak evening it serves 1.4 million concurrent viewers, and its load has a sharp shape: in the 10 minutes before a top-league kick-off, the rate of stream starts rises 30×, because fans open the app at the last moment. Every stream start needs a license from one of two digital rights management (DRM) providers, external services that decide whether a given viewer may decrypt a given stream. All competitions share one pool of playback-API instances, and the Sunday-evening derby alone takes 40% of that pool.

Last month one DRM provider slowed down. Its latency rose from 120 ms to 5 s and stayed there for 25 minutes. Three layers then retried at once: the player SDK on the viewer’s device, the playback API, and the fans themselves, restarting the app when nothing appeared. Together they quadrupled the volume of license requests. The shared pool saturated, and stream starts failed for every competition, including those licensed through the other provider, which had been healthy all along. The slow provider recovered at 20:31. Matchday itself recovered at 21:40, and some 210,000 viewers missed the whole first half.

The story has the shape this chapter has been teaching us to recognize. A single integration point, the slow DRM provider, became a cascading failure because the timeouts were too patient, the retries multiplied across layers, and the shared pool gave the derby and the slow provider a way to drag down everyone else. The most instructive number is the gap between 20:31 and 21:40. For 69 minutes the trigger was gone and the system stayed down anyway, which is the signature of the metastable failure of Section 5.3. The deliverables below ask you to take the incident apart in the order the chapter did, and then to design the rehearsal that would have caught it before a derby did.

Deliverables:

  1. Integration-point register — Map the stream-start path from the player to the playback API and on to each DRM provider, as Section 5.1 did for Encore. For every call on that path, derive a timeout from a 4 s time-to-first-frame budget, the time a fan may wait between pressing play and seeing the picture. Divide the budget among the hops as Figure 5.2 divided Encore’s checkout, and leave a margin for queuing.
  2. Retry and breaker design — Choose one layer to own retries, give it a retry budget and jittered backoff, and say what the other layers do instead. In particular, design throttling in the player SDK, because a million devices retrying in step are the largest retry layer Matchday has. Add a circuit breaker per DRM provider, and make it consistent with that provider’s timeout, so that the breaker opens on the slowness that last month’s provider actually showed and does not wait for errors that never came.
  3. Shedding and metastability analysis — Design admission control for the pre-kick-off surge, and set the order in which work is shed when admission is not enough. Then name the three parts of last month’s metastable failure: the vulnerable state the system was running in, the trigger, and the sustaining effect that kept it down after the trigger was gone. Finish with the runbook text that would have ended the incident by 20:40, written for an on-call engineer who must act on it without hesitating, even though the action will look like an overreaction.
  4. Blast-radius plan — Choose the rungs of Figure 5.5 that Matchday needs. The plan must achieve two things: the derby can no longer starve the other matches of playback capacity, and a stream that is already playing survives the loss of the providers that started it.
  5. Game-day plan — Design one experiment in the spirit of Section 5.5. State a hypothesis that could turn out false, the failures you will inject, the conditions under which you will stop, and the human step you most want to watch: the moment when a person, not a machine, has to recognize what is happening and decide what to do.

Rubric:

Criterion The question to ask yourself
Budget-derived timeouts Does each timeout follow from the 4 s budget and from a false-timeout rate you chose on purpose?
One retry layer Have you counted the player SDK’s retries and the fans’ own restarts, as well as the server’s?
Shedding order Are streams already playing protected before new starts are admitted?
Sustaining effect Does your analysis explain the 69 minutes between the provider’s recovery and Matchday’s?
Isolation and static stability Is the derby contained without a cell per match, and does a playing stream need nothing new while the incident lasts?
Experiment honesty Could the hypothesis fail, and is there a clear point at which you stop?

Where you now stand

You can now trace a failure along the integration points it travels, derive timeouts from a latency budget instead of inheriting library defaults, and tune retries and circuit breakers so that they calm an incident rather than feed it. You can shed load deliberately, recognize a metastable failure by the way it outlives its trigger, choose the bulkhead whose size fits the failure you fear, and test all of it in a game day with people in the room, since people are half of every recovery. Every one of these techniques, however, rests on an assumption we have not yet examined: that the data underneath survives. A process can be restarted, a pod rescheduled and a cell rebuilt, but none of that brings back a lost write. Chapter 6 turns to state, and to disaster recovery practiced until it becomes routine.

References