ealeng

Episode 42 of 55 · Overload

Hold the garnish: skipping the extras answered every buyer in time, and a circuit breaker stopped waiting on a slow service

A flash sale at 1,000 bookings a second on four servers answered 47.4% of buyers in time when every booking did everything. Skipping two optional steps when four bookings were waiting answered 100%, sold all 50,000 seats and double-booked none. Then a recommendations service that took two seconds to answer left no booking in time until a circuit breaker stopped waiting for it, and an autoscaler could not catch a 10-second spike, because a new server took 30 seconds to start.

Lab 17 · Overload, Rate Limits and Backpressure15 min read
Video transcript10:28

0:00Cold open

0:01

A flash sale: a thousand bookings a second, five times the usual, on the same four servers.

0:09

With every booking doing everything, only forty-seven percent of buyers got an answer in time. The rest were turned away.

0:18

Then I let the servers skip the optional parts when they’re busy. Not one buyer was told “busy”, every seat sold, and not one was sold twice.

0:29

And autoscaling? Against a ten-second spike, it changed nothing: five thousand nine hundred eleven requests failed with it, and five thousand nine hundred eleven without.

0:42

So what actually saves a system when the crowd shows up?

0:47Intro

0:49

Hands-on system design, part forty-two.

0:52

Today: a flash sale, a slow service we depend on, and an autoscaler that arrives too late.

1:00Meet Lucía

1:01

I’m Lucía, a platform engineer, and tonight we sell fifty thousand seats for one event.

1:07

Each booking does three things. First, it books a seat: one quick update in the database. That’s the part that matters.

1:16

Then two extras: a “you might also like” list from another service, thirty milliseconds, and a count of seats sold.

1:25

Think of a restaurant kitchen on a rush night. Each worker is a cook, making one dish at a time. The extras are the garnish. Degradation means holding the garnish when the line is long.

1:38

A circuit breaker means you stop phoning the supplier who never picks up. And autoscaling is calling in more cooks, who take a while to arrive.

1:4901 · What you need

1:51

To run it yourself, you need Docker: the service, its database and a load simulator all run on one laptop. The quick tests run in a couple of seconds, without Docker.

2:03

No cloud, and nothing to pay for.

2:0802 · The sale

2:09

The setup: four servers, each with four workers. A booking holds a worker until it’s done.

2:17

Each server lets at most thirty-two bookings wait. The next one gets a fast five-oh-three, which means: busy, try later.

2:26

The buyers are simulated, one seat each. They wait one second for an answer, and don’t retry.

2:34

Two hundred bookings a second, then one minute at a thousand: five times as many. Then two hundred again.

2:4303 · Doing everything

2:44

First, every booking does everything. During the minute of the sale, forty-seven percent of buyers got an answer in time.

2:53

The other fifty-three percent got a fast five-oh-three: thirty-one thousand buyers told “busy”.

3:01

Why? A full booking holds a worker thirty-three milliseconds, mostly waiting on recommendations. Four servers manage about four hundred eighty a second.

3:13

Even the lucky ones waited. A typical answer took three hundred milliseconds: thirty-two bookings ahead of you, four served at once. That’s eight turns of thirty-three milliseconds before yours.

3:26

And at the end, thirteen thousand six hundred sixty-six seats were still unsold, while buyers had been sent away.

3:3604 · Hold the garnish

3:37

The change is a few lines. When a booking arrives, the server looks at how many are waiting. Four or more: degrade.

3:46

The seat is always booked. The two extras run only when the line is short.

3:52

Nothing is refused. The buyer still gets a seat, just without the garnish.

3:5905 · Skipping the extras

4:01

Same sale, same four servers. This time, the extras are skipped whenever four bookings are waiting.

4:08

How many buyers do you think were turned away now?

4:14

None were told busy. Every buyer got an answer within the second, and all fifty thousand seats sold.

4:22

Why? Without the extras, a booking holds a worker for a few milliseconds of database work, not thirty-three. Fifty-five percent of the answers came without them.

4:34

And in both runs, not one seat was sold twice. Each seat is one atomic update, all or nothing, so two buyers can’t get the same seat. And a refused booking never touches the seats.

4:4806 · Sold out

4:50

Here are the answers per second, through the sale. Doing everything: flat, at about four hundred seventy.

4:58

Skipping the extras: about a thousand a second, the whole minute.

5:03

One honest detail. The seats ran out at sixty-six seconds, forty-six seconds into the sale.

5:11

After that, buyers heard a quick “sold out”. Nobody timed out, and nobody heard “busy” while seats were left.

5:2107 · A slow dependency

5:22

Now a different problem. Normal traffic, two hundred bookings a second. Ten seconds in, recommendations, the service we depend on, gets slow: two seconds per answer.

5:34

The booking service waits up to one second for it. The buyers also wait one second. So it waits as long as the buyer does, and can never answer in time.

5:45

Without a breaker, from then on, not one booking got through in time.

5:52

Why? Sixteen workers in all, each stuck a full second: just sixteen bookings a second, all too late. Everyone else got a fast five-oh-three.

6:02

Worse: a timeout isn’t a no. The seat is booked first, then the service waits for recommendations. So about six hundred buyers got a seat after they’d given up.

6:1508 · The breaker, in code

6:17

A circuit breaker sits in front of the call. It watches the last five seconds. Twenty calls or more, half of them failed: it opens.

6:26

Open means: for three seconds, every call fails at once, without waiting for recommendations.

6:34

Then it lets three test calls through. If they all work, it closes again. If one fails, it opens again.

6:4309 · With the breaker

6:44

With the breaker on, it took about five seconds to open: for five seconds it still remembered the good calls from before, so the failures weren’t yet half. After that, ninety-eight and a half percent got through, typically in under two milliseconds.

7:00

Faster than before the slowdown, when a booking took about thirty-three milliseconds, because bookings no longer waited for recommendations at all.

7:10

Seventy-two bookings still timed out. They match its test calls: every few seconds, three bookings on each server try recommendations again, and each waits the full second.

7:23

So slow is the dangerous kind of failure. A fast “no” costs milliseconds. A slow one costs a worker for a second.

7:3410 · Autoscaling a spike

7:35

Last: autoscaling, on a simpler request: twenty milliseconds of work, so two hundred a second per server. It starts with two servers.

7:45

It checks how busy each server is, requests waiting or in progress, and averages its last three readings. Its target is three each; above that, it asks for more. A new one takes thirty seconds to start.

8:00

Then a spike: ten seconds at a thousand a second. Sixty percent failed. Two servers serve four hundred a second, so six hundred of every thousand were refused.

8:12

The autoscaler noticed within about a second, and asked for six servers. Even normal traffic nudged it over three now and then, so it had already asked for one more.

8:24

They were due to be ready at sixty-two to sixty-four seconds: over twenty seconds after the spike ended. The early one was too late too.

8:34

With the autoscaler off: five thousand nine hundred eleven failed too. The same arrivals met the same two servers.

8:4411 · A slow climb

8:46

Now the same autoscaler against a slow climb: from two hundred to a thousand a second, over five minutes.

8:54

The room grew with the load. Each new server was ready about thirty seconds after it was asked for, while the load was still climbing slowly.

9:04

Not one failure, in two hundred fourteen thousand requests.

9:10

An earlier version reacted to single readings, with more base traffic: three hundred a second. A high reading a second into the run started extra servers before the spike. Two were due to be ready during it: thirty-eight percent failed, not sixty-one.

9:27

So capacity helps a spike only if it’s already there, or at least already starting: spare room, refusing the extra fast, or scaling up before an event you know is coming.

9:40Back to Lucía

9:42

So, three lessons.

9:44

When the crowd comes, do only the part that matters. Correctness doesn’t change.

9:51

A slow dependency is worse than a dead one: a fast “no” costs milliseconds, a slow one costs a worker. Put a breaker in front of it, and give up on it before your buyer gives up on you.

10:04

And autoscaling follows ramps, not spikes.

10:09

Next time: failover, when a server doesn’t slow down, but dies.

10:15

For today: hold the garnish.Lucía: Hold the garnish.

10:18Summary

10:20

Skip the extras under load, break the slow call, and have room for a spike before it comes.

Key takeaways

  • ✓When every booking did everything, the four servers answered 47.4% of 59,693 buyers in time during the minute of sale: a full booking held a worker for about 33 ms, mostly waiting for the recommendations service, so the other 52.6% got a fast HTTP 503, meaning busy, try later.
  • ✓Skipping the two optional steps (the recommendations call and the seats-sold count) whenever four bookings were waiting answered 100% of buyers in time at 995 bookings a second, with 55% of the answers served without the extras, and all 50,000 seats sold.
  • ✓Skipping the extras never double-booked a seat: 0 seats were sold twice in either run, because each seat is one atomic update (a single database change that either completes or does not) and a booking that is skipped or refused never reaches the seat count.
  • ✓Autoscaling changed nothing against a 10-second spike at 1,000 requests a second: 5,911 of 9,828 requests failed with the autoscaler on, and the same 5,911 with it off, because a new server took 30 seconds to start and the first one served 5 seconds after the spike ended.
  • ✓A slow dependency is worse than a dead one: with recommendations answering in two seconds against a one-second timeout, no booking was answered in time for 25 seconds, while a circuit breaker that stopped calling it brought the answered share back to 98.5%, with a median answer of 1.8 ms.
  • ✓Autoscaling can follow a slow climb: from 200 to 1,000 requests a second over five minutes, with servers added as the load rose, 214,119 requests had 0 failures, with the server count going from 2 to 6.

Four servers, one flash sale at a thousand bookings a second, and half the buyers were told "busy". Skipping two optional steps while the servers were busy told nobody "busy" and sold every seat. A slow service that the booking depended on then answered no buyer in time, until a circuit breaker stopped waiting for it. The last test asked whether an autoscaler, which adds servers when load rises, could catch a spike. It could not.

The examples come from Lab 17 (Overload, Rate Limits and Backpressure) of the system design labs: script 04_flash_sale.py for the sale and the slow service, and script 05_autoscale.py for autoscaling, with the breaker's code in breaker.py. Both scripts run on the same laptop setup as the earlier chapters, an Apple M4 Max with Docker Desktop and 16 virtual CPUs. The four servers, their database and a load simulator all ran in Docker. The simulated buyers wait one second for an answer and do not retry. Each configuration is one recorded run, and the README puts scripts 01 to 05 at about 40 minutes.

A booking has an essential part and extras

Each booking does three things. It books a seat, which is one quick update in the database. That is the part that matters. It also asks a recommendations service for a "you might also like" list, which takes about 30 ms, and it counts the seats sold, which is a cheap read.

The servers have four workers each, and a booking holds a worker until it is done. Each server lets at most 32 bookings wait. A booking that arrives when the line is full gets the fast 503 at once, instead of waiting for a worker that will not come in time.

Think of a restaurant kitchen on a rush night. Each worker is a cook making one dish at a time. The recommendations are the garnish. Degradation means holding the garnish when the line is long: the dish still goes out, just without the extra. A circuit breaker is the cook who stops phoning a supplier who never picks up. Autoscaling is calling in more cooks, who take a while to arrive.

The sale, doing everything

Doing everything, a full booking holds a worker for about 33 ms, and most of that is waiting for recommendations. Four servers with four workers each finish about 120 bookings a second per server, roughly 480 for the four. The sale offered 1,000 a second for a minute.

The lucky buyers waited too. A typical answer took 301 ms at the median: 32 bookings were queued ahead on a server, and four were served at once, so a buyer waited about eight rounds of 33 ms before their own booking began. At the end of the sale, 13,666 of the 50,000 seats were still unsold, while 31,415 buyers had been sent away.

Degradation, in code

The change is a few lines. When a booking arrives, the server looks at how many bookings are waiting. If there are four or more, it skips the recommendations call and the seats-sold count, and it still books the seat. The extras run only when the line is short.

Nothing is refused by this rule. A buyer whose booking was degraded still gets a seat, just without the garnish. The rule decides what work a booking does, not whether it is allowed to book. Refusal is a separate mechanism: the 503 comes from the queue being full, and it happens to bookings that arrive when the queue has no room.

Skipping the extras

With the same sale and the same four servers, the extras are skipped whenever four bookings are waiting. Without the recommendations call, a booking holds a worker for a few milliseconds of database work, not 33. The 55% of answers that came without the extras are the ones that kept the line short.

  • Doing everything: 47.4% answered in time; 31,415 fast 503s; 36,334 of 50,000 seats sold.
  • Skipping the extras when four wait: 100% answered in time; 0 fast 503s; all 50,000 seats sold.

The answers per second show the difference across the minute of sale. Doing everything stayed flat at about 471 a second. Skipping the extras held about 995 a second for the whole minute, because the same four servers could keep up with the five-times peak.

Try it · A flash sale at 1,000 bookings a secondrecorded run, 04_flash_sale.py

Every booking calls recommendations and counts the seats sold. A full booking holds a worker for about 33 ms, so the 16 workers across four servers run out of room, and the overflow is refused with a fast 503 ("busy, try later").

Answered in time
47.4%
Booked per second
471
p99 latency
316 ms
Fast 503s
31,415
Answers in time, per second, over the 60 s sale (offered: 1,000 a second)
start of saleend of sale
Seats sold: 36,334 of 50,000. 13,666 were still unsold when the sale ended.
Double-booked seats: 0 in both modes. Skipping the extras never touches the seat count.

Nobody was double-booked in either run. Each seat is one atomic update, so two buyers cannot both win the same seat. A degraded or refused booking never reaches that update, so it cannot take a seat that someone else already has.

One honest detail from the run: the seats ran out before the sale ended (about 9,700 of the 59,693 answers were "sold out"). After that, buyers heard a quick "sold out" answer. Nobody timed out, and nobody heard "busy" while seats were left. In the lab, a "sold out" answer counts as a successful answer, because it came in time. The 100% figure therefore means every buyer got a timely answer, not that every buyer got a seat.

A slow dependency is worse than a dead one

Now a different problem. The booking service still gets 200 bookings a second, and from about 10 seconds into the run, the recommendations service takes two seconds to answer. The booking service waits at most one second for it. The buyers also wait one second. So each booking waits as long as its buyer does, and it can never answer in time.

Without a breaker, from then on, no booking was answered in time for 25 seconds. The reason is capacity. Sixteen workers in all, each stuck for a full second, can finish only about 16 bookings a second, and every one of them is too late. The rest got a fast 503. The recommendations service was optional, and it still took the whole service down.

A timeout is not a no. The seat is booked before the recommendations call, so a booking that waited out the timeout had already taken its seat for a buyer who had given up. In the run with the breaker off, 2,617 seats were sold but only 2,009 bookings got a recommendations answer back, so about 600 seats were taken for buyers who had already timed out. That figure is a subtraction from two counts in the results, not a count the lab made directly.

A fast refusal costs a request a few milliseconds. A slow one costs a worker for a second. That is why the slow case is the dangerous one, and why the lab's own question about a service that answers 503 at once is easier: a dead dependency is cheap, a slow one is expensive.

Circuit breakers: closed, open, half-open

A circuit breaker sits in front of a call and remembers how the call has been going. It has three states.

  • Closed: calls go through, and each outcome is counted over the last 5 seconds. Timeouts count as failures. If at least 20 calls were made in that window and at least half failed, the breaker opens.
  • Open: every call fails at once, without touching the dependency, for 3 seconds.
  • Half-open: after the 3 seconds, the breaker lets three trial calls through. If all three succeed, it closes again and forgets the old window. If one fails, it opens again for another 3 seconds.

The same numbers are in breaker.py, which is written from scratch for the lab. Each booking server runs its own breaker, with a failure share of one half, at least 20 calls, a 5-second window, a 3-second open period and three probes.

Try it · A slow recommendations servicerecorded run, 04_flash_sale.py

Recommendations get slow: two seconds per answer, and the app gives up after one. Every booking waits the full second, so no booking answers its buyer in time, and the buyers give up after one second too.

Answered in time
0.0%
p50 latency
none
Timeouts
395
Recommendation calls skipped
0
Answered, of 4,909
Breaker state at the end of the run, on all four servers: closed, because the breaker is off.
Closed

Calls go through, and the outcomes (including timeouts) are counted over the last 5 seconds.

Opens when at least 20 calls were made and half of them failed.

Open

Every call fails at once, without touching the service, for 3 seconds.

Then the breaker moves to half-open.

Half-open

Three trial calls go through. If all three succeed, the breaker closes. If one fails, it opens again.

With the breaker on, the breaker took a few seconds to open. The results do not record the moment it opened, so the time it took (about five seconds) is an estimate. During those seconds, the window still held the good calls from before the slowdown. After it opened, bookings no longer waited for recommendations at all. The breaker's table shows 98.5% of the slow-phase bookings answered in time, at a median of 1.8 ms and a 99th percentile of 6.3 ms. That is faster than before the slowdown, when a booking took about 33 ms.

Some bookings still timed out: 72 in the slow phase. The results do not say which calls they were. Most likely they are the three trial calls each server makes every few seconds, plus requests caught in the seconds before the breaker opened. The lab's README attributes them to the seconds before it opened, and the probes are the other likely source.

Why autoscaling alone did not fix the spike

The autoscaling test used a simpler request, 20 ms of work, so each server handles about 200 a second. The servers started with two, and the autoscaler's rule was to keep the average load per server near three requests waiting or in progress. Every two seconds it averaged its last three readings, and it asked for enough servers to bring the average back to three. A new server took 30 seconds to start.

The first test was a spike: 10 seconds at 1,000 a second, which is more than two servers can handle (about 400 a second). The autoscaler asked for six servers at 30.9 seconds. Those servers started answering at 61.9 and 64.1 seconds, more than 20 seconds after the spike had ended. The first extra server that answered at all did so at 44.6 seconds, 5 seconds after the spike ended.

  • Spike, autoscaler on: 5,911 of 9,828 requests failed (60.1%).
  • Spike, autoscaler off (two servers): 5,911 of 9,828 failed (60.1%).

Two servers were handling 400 a second, so 600 of every 1,000 requests were refused. The autoscaler saw the problem and reacted, but the answer came after the problem had gone. Capacity for a spike has to be there before the spike, or at least already on its way.

The second test was a ramp: from 200 to 1,000 a second over five minutes. The autoscaler added servers while the load was still rising slowly, and each new server came online about 30 seconds after it was asked for. Across 214,119 requests, none failed, and the server count went from two to six. Autoscaling follows ramps. It does not catch spikes.

One earlier run is worth knowing about, because its result looked better. Its base load was set exactly at the autoscaler's target, so a few noisy readings started two extra servers before the spike arrived. The spike then found them ready: 38.3% of requests failed with the autoscaler against 60.7% without. The lab's README calls this an artefact of the base load, not an effect of the autoscaler, and the later run with the base load at half the target shows the same 60.1% either way.

The workflow and the results

The sale and the breaker. Run 04_flash_sale.py (about six minutes). Here p50 is the median answer time, and p99 is the time that 99 answers in 100 beat. It runs the sale twice, once with degradation off and once with it on, each time at 200 a second, then 1,000 a second for 60 seconds, then 200 a second again. It then runs the slow-service test twice, once with the breaker off and once with it on, at 200 a second for 40 seconds with recommendations slowed from about 10 seconds on. The script checks each run for double-booked seats.

Degradation Answered in time (sale) Booked per second p50 p99 Answers without the extras Fast 503s Seats sold Double-booked
Off (doing everything) 47.4% 471 301 ms 316 ms 0% 31,415 36,334 of 50,000 0
On (skip the extras when four wait) 100% 995 36 ms 67 ms 55% 0 50,000 of 50,000 0

Before the sale, both runs answered 100% of bookings in time at about 198 a second, with a median of 33 ms.

Breaker Answered in time (slow phase) p50 p99 Fast 503s Timeouts Recommendations calls skipped Breaker state at the end
Off 0.0% none none 4,514 395 0 closed (never opens)
On 98.5% 1.8 ms 6.3 ms 2 72 4,956 open, on all four servers

Before the slowdown, both breaker runs answered 99.4% of bookings in time, with 8 timeouts each.

Autoscaling. Run 05_autoscale.py (about 12 minutes). It runs the spike with the autoscaler on and off, and the ramp with the autoscaler on.

Run Requests failed before the spike During the spike (10 s at 1,000 a second) After the spike When the servers answered
Spike, autoscaler on 12 of 5,956 5,911 of 9,828 (60.1%) 0 first extra at 44.6 s; four at 61.9 s; six at 64.1 s
Spike, autoscaler off 23 of 5,956 5,911 of 9,828 (60.1%) 0 none extra
Ramp, autoscaler on (200 to 1,000 a second over 5 minutes) 0 of 3,986 0 of 214,119 over the whole ramp 0 from two servers to six

The numbers in the tables come from data/results/04_flash_sale.json, 05_autoscale.json and, for the earlier run, 05_autoscale_at_target.json. The timeline in the autoscaling file records the server count and the desired count about every two seconds, which is where the 30.9-second request and the 44.6-second answer come from. The README says the autoscaler "saw the spike at 36 s". The timeline shows the first request for six servers at 30.9 seconds, so the chapter uses that figure.

Caveats

  • One run per configuration. Every row is a single recording on one laptop, with a load average of 5.4 during the sale run. Treat the counts as a single observation, not a measured average.
  • "Answered in time" counts sold-out answers. A fast "sold out" is a success in the lab's counting, so the 100% in the degradation test means every buyer got a timely answer, not a seat.
  • The seat count in the breaker run is not used. The results file's seats-sold count for the breaker-on run (7,129) is larger than the number of requests in that run, so the chapter does not use it. The 608 figure is a subtraction from two counts, and the lab does not state it.
  • The breaker's timing is estimated. The results file does not record when the breaker opened, and the probe explanation for the 72 timeouts is a likely reading of the lab's README, not a timestamp in the results.
  • Buyers do not retry. The simulated buyers wait one second and give up. Real buyers who see "busy" and try again would add load, which is a different test (the lab's previous episode covers retry storms).
  • Each booking server has its own breaker. The lab does not share breaker state across servers, so each server learns about the slow service separately. The README lists shared breakers as an exercise.
  • Not covered: a breaker's tuning (the 20 calls, 5 seconds, 3-second open period and three probes were chosen for this lab), adaptive limits that follow latency, last-in-first-out serving under overload, scaling on a leading signal such as the queue in front of the servers, and multi-region traffic. The lab lists several of these as exercises.

The checklist

  1. Find the part that must always run. Keep the essential work (here, the seat update) on every request, and make the optional work the first thing to drop.
  2. Check that shedding and degradation cannot change correctness. The seat count is one atomic update, and anything skipped or refused never reaches it.
  3. Put a breaker in front of any dependency that can get slow. A fast failure costs a request milliseconds. A slow one costs a worker for its full timeout, so a breaker that opens on slow calls protects the whole service.
  4. Give up before your caller does. The breaker's open period and the timeout should be set so that the service stops waiting before the buyer gives up.
  5. Plan capacity for spikes before they come. An autoscaler follows a ramp, and its new servers take time to start. A spike needs headroom, shedding, or a scale-up scheduled before a known event.

Quiz

Try it · Check your understanding0 of 3 answered
  1. 1.Four servers each run four workers, and a full booking holds a worker for about 33 ms. Roughly how many bookings a second can the four servers finish?

  2. 2.A circuit breaker is open. What happens to the next call to the recommendations service?

  3. 3.The autoscaler saw the spike and asked for more servers, yet the spike's failures were the same with and without it. What explains that?

Check your understanding

Try each question before opening its answer.

Why did skipping the extras answer every buyer in time, when the same four servers answered only 47.4% when they did everything?

Because a full booking held a worker for about 33 ms, mostly waiting for the recommendations call, so four servers finished only about 480 bookings a second. Without the recommendations call and the seats-sold count, a booking held a worker for a few milliseconds, and the same four servers kept up with 995 bookings a second, with the 55% of answers that came without the extras.

Skipping the extras kept the seat count right in both runs. What is it about the seat update that makes that true?

Each seat is one atomic update: a single database change that either completes or does not, so two buyers cannot both take the same seat. A booking that is skipped or refused never reaches that update, so it cannot take a seat that someone else already has. In both runs, 0 seats were sold twice.

A circuit breaker is open. What happens to a booking that arrives, and why is that better than the recommendations call timing out?

The booking fails at once, without calling the recommendations service, and the buyer gets a fast answer. A timeout would have held a worker for a full second first. The breaker stays open for 3 seconds, then lets three trial calls through to see whether the service has recovered.

The autoscaler saw the spike and asked for six servers. Why did the spike fail the same number of requests with it on and off?

Because a new server takes 30 seconds to start. The autoscaler asked at 30.9 seconds, the first extra server answered at 44.6 seconds, and the spike had already ended about 5 seconds earlier. Those extra servers answered only after the requests that needed them had failed, so the same 5,911 requests failed either way.

The breaker on the slow service answered 98.5% of bookings in time, against 0% without it. Why is a timeout worse than a fast refusal here?

A timeout holds a worker for the full second the service takes to fail, so capacity drops to about 16 bookings a second across the four servers, and every booking waits. A fast refusal costs a few milliseconds. The breaker turns the slow failures into fast ones, so the workers stay free for the bookings that can still be answered.

Next up: Chapter 43, failover and lost writes. This chapter's server slowed down and stayed up. The next one is a server that dies, and the question is which writes were acknowledged and then lost.

Learning something useful?

New labs, articles, and videos on evaluating and testing AI systems come out regularly. Follow along so you don't miss the next one.