ch24 · What the model got wrong
The question
The design failed. Can the model say why, and what can it never say?
Every chapter so far has ended before anything happened. This chapter is set at the model’s horizon — the end of the refresh cycle the fleet was bought against. By then the busy hour has grown for the whole horizon, and the fleet either carries it or does not. It is the only chapter in the book where the model is the defendant.
Nothing here is an observation
No system was watched and no invoice was read. What follows is the model’s own futures,
filtered to the ones in which the design failed. That is what makes it reproducible, and it is
also what bounds what it can say. A real post-mortem compares a prediction against
something that happened. That is the estate target (ch03), and
it belongs to whoever runs the system.
The material
The model said this would happen
Start with the uncomfortable half. The fleet ch12 bought was the one the point estimates recommended, and the same model reported this about it:
| Ceiling | At the plan | Headroom | Allowed | Limit | Verdict | Over allowed | Over limit |
|---|---|---|---|---|---|---|---|
| working set against memory | 0.75 | 25% | 0.75 | 1.00 | ok | 49% | 35% |
| utilisation, counting coordination | 0.95 | 30% | 0.70 | 1.00 | into the margin | 65% | 48% |
| disk fill at horizon | 0.67 | 25% | 0.75 | 1.00 | ok | 44% | 29% |
| utilisation with one host down | 0.66 | 30% | 0.70 | 1.00 | ok | 47% | 30% |
| utilisation at the busy hour | 0.64 | 30% | 0.70 | 1.00 | ok | 46% | 30% |
| fraction of the fleet doing nothing useful | 0.32 | 50% | 0.50 | 1.00 | ok | 1% | 0% |
Source — web_service-reference · the model to explore; each input with a range has a slider
The Over limit column shows utilisation at the busy hour went over its limit in a substantial share of the futures the model thought plausible. Its limit is one, every core busy, in the Limit column, not the Allowed one. Its Verdict is ok; the plan sat below its Allowed figure with the margin untouched at the point estimate, so these are failures the point estimate did not show. The row utilisation, counting coordination had a larger Over limit share, but its Verdict was already “into the margin”. Other ceilings had their own Over limit shares; the working set outgrew memory in more futures than the busy hour went over its limit. Nobody was misled. Nothing was hidden. The figures were on a page.
This is the first finding here: the failure was forecast, in writing, by the people it later surprised. What went wrong was not the model. A percentage in a table is not an event, and a number nobody has to sign for is a number nobody reads out loud. That is all of ch21, arriving too late to help.
Where the failures were
Now the part the model can do well. The sampled futures already contain the failures. They are the draws where the queueing ceiling, utilisation at the busy hour, came out over its limit. So the question what went wrong is a filter. Take those draws, and look at what each input had been doing in them.
| Input | Its usual value | In the failures | Shift | Extreme in |
|---|---|---|---|---|
| peak request rate, day one (request/second) | 9,905 | 12,463 | +26% | 21% of them |
| annual growth factor | 1.34 | 1.52 | +14% | 31% of them |
| CPU time per request (core-seconds / request) | 0.0131 | 0.0145 | +11% | 19% of them |
| 3 inputs | 30% of futures ended here | something was beyond its p90 in 58% of them, against 25% of futures generally |
Source — postmortem · sizing.evaluate
Read the Shift column. All three inputs sit higher in the failures than they do across all the futures, and none by much. The peak request rate on day one moved furthest from its usual self, annual growth next, the CPU time per request last. Utilisation at the busy hour is the day-one peak, grown to the horizon, times the CPU time each request costs, over a fixed number of cores. None sits where it usually does, because the three meet in one multiplication, and any of them being a little high can carry that product over its limit.
Now read it against ch04’s tornado of the peak request rate at the horizon, before any fleet is chosen, and ch19’s value-of-information table. Both put growth first: in ch04’s tornado, it is well ahead of the day-one busy hour, and in ch19’s table, well ahead of the rest. The column here ranks by how far each input moved, not by what the move did, and the two orderings differ for a structural reason. Growth moved less than the busy hour did and did more, because the horizon raises it to a power. So these are three different questions: what moves the answer, what is worth measuring, and what broke it. The third has to be read with the model’s shape beside it. Otherwise it ranks the inputs by how they were written down rather than by what they do.
Many failures had no culprit
An input is extreme here when it came out above its own ninetieth percentile, worked out across all the futures. Only the upper end counts: an unusually low value is not extreme here. In plain words, it is the kind of value you would call unusual afterwards.
In a large minority of the failures, nothing was extreme. The busy hour was a little above its usual. Growth was a little above average. A request took a little longer. That was enough to take utilisation at the busy hour over its limit. Read the bold 3 inputs row at the foot of the attribution table, in the Extreme in column. That cell gives the share of failures in which something was extreme; the failures with nothing extreme are the rest.
This is the sentence a post-mortem culture is worst at accepting, because it is nobody’s fault and it makes a poor slide:
Some of the failures have a story. A large share of them do not: nothing remarkable happened, something unremarkable did, and there was no margin for unremarkable.
A failure with nothing extreme in it is a finding about the margin the fleet was sized with, not about anything that happened: an ordinary busy hour was more than that margin could absorb. The account a team tells afterwards tends to be about one dramatic thing, because a dramatic thing can be pointed at. This finding only turns up if you look for it.
In most of the failures, something was extreme. That share means something only beside a second figure, which the same cell gives: the share of all futures, failed or not, in which something was extreme. Call this the base rate. Against its base rate the finding holds: the failures contain an extreme input far more often than futures at large.
Every input is above its own ninetieth percentile in one future in ten, by definition. The more uncertain inputs a model has, the more often at least one of them is extreme in any future, whether or not it failed. A post-mortem that reports “something was unusual” without its base rate has discovered how many inputs the model has.
The same method, on a model with a hole in it
The observability model has a node for spans per request (spans_per_request), a measured constant
that nobody has measured yet; the box below names it. A node with no value, and everything
downstream of it, takes part in none of the futures the model draws, so the whole traces chain is in
the file but in none of the samples. The ingest figure the model can compute is ingest, metrics and
logs only, which leaves traces out (ch20):
Not measured yet
observability declares 2 constant(s) that nobody has measured:
collector throughput per core, measured — needs
bench/results/collector-throughput-per-core.jsonspans per request — needs
bench/results/traces-spans-per-request.json
6 node(s) downstream of those cannot be computed. In the book’s tables they are shown as not yet measured; on the interactive model page their boxes show —. Nothing is estimated in their place: this book publishes measurements or it publishes nothing.
Source — observability-reference · the model to explore; each input with a range has a slider · 2 measured constants have no measurement yet, so figures that depend on them say not yet measured (why)
Run the identical attribution against its ingest ceiling, and it is happy to help:
| Input | Its usual value | In the failures | Shift | Extreme in |
|---|---|---|---|---|
| extra accidental label values | 1.44 | 2.47 | +71% | 24% of them |
| request rate (request/second) | 38,412 | 57,274 | +49% | 29% of them |
| lines per request (line/request) | 13.1 | 19.1 | +45% | 28% of them |
| annual growth | 1.40 | 1.59 | +14% | 30% of them |
| different endpoint label values | 8.78 | 9.20 | +5% | 11% of them |
| different status label values | 3.55 | 3.60 | +1% | 11% of them |
| bytes per sample, compressed (bytes / sample) | 9.37 | 9.37 | none | 10% of them |
| bytes per log line, compressed (bytes / line) | 32.4 | 32.4 | none | 10% of them |
| 8 inputs | 22% of futures ended here | something was beyond its p90 in 85% of them, against 55% of futures generally |
Source — postmortem · sizing.evaluate
The rows are specific and ranked. Not one of them mentions spans per request, because the attribution can rank only inputs that were drawn, and spans per request never was. Two rows would have a share in the cause if traces filled the pipeline: request rate, the second row, and annual growth, the fourth. Both feed the traces chain as well: span rate is request rate times spans per request times the trace keep rate times the growth factor. The other rows (the label values, lines per request and the byte sizes) feed only metrics and logs. The table ranks the inputs as if they were the whole cause. If traces filled the pipeline, it ranks the wrong things in the order they look guilty.
A post-mortem inside a model is a post-mortem of that model. It can tell you which of the things you thought of was responsible. It cannot tell you that you thought of the wrong things, and it will not decline to answer.
The loop this closes
This chapter closes a cycle the book teaches. Here is the cycle, named in full for the first time:
model → measure → predict → build → observe → compare → update
Model: Parts I to III built the web service model — the demand in Part I, the ceilings in Part II, the sizing in Part III.
Measure: Part I said where each number may come from, and ch19 said which input to go and measure, and whether measuring it pays.
Predict: Part IV turned the model into a range of futures instead of one number, Part V priced it over the horizon, and Part VII put the prediction in front of the people who pay for it.
Build and observe: no part of the book does these; you do.
Compare: this chapter, which compares the model with its own futures, not with a system that ran.
Update: the step after compare, and the only one that makes the next model better than this one; it is yours.
Compare needs a prediction recorded before the fact, with its interval, its inputs, its date and a hash of the code that produced it. That requirement is unglamorous, and it is why this repository is shaped the way it is. A forecast reconstructed from memory afterwards is not evidence, because memory adjusts, and the adjustment always runs in the direction that makes the present bearable. Every stamped result in this book exists so that somebody who was not there can make the comparison without taking anybody’s word for it.
How big, how much, and how wrong
The preface posed one question: How big, how much, and how wrong could I be?
How big: Part III answered it with a chain of multiplications and a number you could put on a purchase order. How much: Part V answered it over a horizon, split between the invoice that gets a meeting and the one that does not. How wrong could I be: the book answered it in two steps. First by running the sampling that Part IV teaches, on inputs written down throughout the book. Then, in ch20 and in the section on a model with a hole in it earlier on this page, by showing the part of the answer that sampling cannot reach.
A model can tell you how wrong its inputs might be. Nothing in it can tell you that the model is the wrong shape, and a method that claimed otherwise would be the most dangerous thing in this book.
What this cannot tell you
Whether the cause was in the model at all. The whole chapter conditions on the model’s own samples, so every answer it can give is drawn from the list of things the model’s author already declared. ch20 is the failure mode, and this chapter demonstrates it rather than escaping it.
A cause from a correlate. Two inputs that move together are equally implicated by this method, and the model’s declared correlations guarantee there are such pairs (ch14). Attribution finds what is associated with failure. What caused it is a claim about mechanism, and the mechanism is the part of the model nobody sampled.
Anything about a failure with no ceiling. The filter is a ceiling being breached. A design that failed in a way nobody declared a limit for produces no failing samples to condition on, and this chapter reports serenely that nothing went wrong.
What to do about it. The busy hour being the cause does not say whether to buy more hosts, shed load, or move the margin. Attribution is a diagnosis. This book has been careful throughout not to pretend a diagnosis is a remedy.
Whether any of this happened. It did not. These are computed futures. The only way to run this chapter against reality is to have written the prediction down first and to observe the system afterwards, and a book can do neither for you.
Key takeaways
The failure was forecast, in writing, by the people it later surprised. A percentage in a table is not an event, and a number nobody has to sign for is a number nobody reads out loud.
Inside the model, what went wrong is a filter. Take the futures in which the ceiling was breached and look at what each input was doing in them.
What broke it, what moves the answer and what is worth measuring are three different questions. Attribution ranks inputs by how far they moved, and has to be read with the model’s shape beside it.
Many failures had no culprit. In a large minority of them nothing was extreme. Several inputs were a little above usual, and there was no margin for unremarkable. In most failures something was extreme, and that share means something only beside its base rate — how often something is extreme in any future, whether or not it failed.
A post-mortem inside a model is a post-mortem of that model. It ranks the inputs the model has without hesitating, and never names the chain that is missing.
Problems
Three, in tests/what_the_model_got_wrong/. The first two have tests, and both work on the web
service’s failures, not on the model with a hole in it. 23.1 ranks the inputs the way the
attribution table does; 23.2 counts the failures in which nothing was extreme. The last has no
test.
24.1 — Attribute the failure. Given the draws and which of them failed, rank the inputs by how far each one had to be from its ordinary self. Use a median, and order by the size of the shift rather than its sign. An input that is unusually low in the failures is just as much of a cause.
def attribute(draws: dict[str, np.ndarray], failed: np.ndarray) -> list[tuple[str, float]]:
"""Problem 24.1 - which input was doing something unusual when the design failed?
``draws`` is one array per uncertain input, all the same length: the values that were drawn
together, sample by sample. ``failed`` is a boolean array of the same length, true in the
samples where the design was asked to do something it could not.
Return ``(name, shift)`` pairs, ordered with the largest shift first, where *shift* is how far
that input's typical value in the failures sits from its typical value across everything, as a
fraction of the latter. An input that behaves the same way in the failures as it does anywhere
else gets a shift near zero, and belongs at the bottom.
Use a median rather than a mean. Every input in this book is skewed, and a mean would report a
shift that is mostly the tail moving rather than the ordinary case changing.
Two things the tests check that are easy to miss. An input that never varies has no shift and
must not raise. And the ordering is by *size* of shift, not by sign: an input that is unusually
low in the failures is exactly as much of a cause as one that is unusually high.
"""
raise NotImplementedError("problem 24.1")The same check at a desk: python3 -m pytest tests/what_the_model_got_wrong/test_problem_1_attribute.py -m problem
24.2 — How often is there a culprit? Work out the share of failures in which no input was above its own ninetieth percentile. Each input’s percentile comes from all the draws, not from the failing ones alone. Only the upper end counts: a value is extreme when it is above the percentile; a value below the tenth percentile is not extreme here, however unusual. This differs from 23.1, where a low shift counted as much as a high one. The function returns the share in which nothing was extreme. The attribution table prints the other share: the failures in which something was.
The tests build their own cases. One case has eight inputs drawn with no connection to which futures failed. Before you run the tests, work out on paper what share of failures that eight-input case should give. You need one fact: each input is above its own ninetieth percentile in one future in ten, independently of the others and of the failure. Write your working in a comment in the stub. The test holds your function to that arithmetic, so a pass means your function and your working agree. Since the eight inputs have nothing to do with the failure, whatever share of failures has something extreme in it is the base rate. A last test runs your function on the web service’s own futures and holds it to the figure the build publishes.
def share_with_nothing_extreme(
draws: dict[str, np.ndarray], failed: np.ndarray, percentile: float = 90.0
) -> float:
"""Problem 24.2 - how often the story afterwards is allowed to be about one dramatic thing.
Same arguments as ``attribute``. Return the fraction of the failing samples in which *no*
input was above its own ``percentile``, taken across all the draws and not the failing ones
alone. The name says what it returns: the share in which nothing was extreme, not the share in
which something was. The attribution table prints the other one.
Only the upper end counts. A value is extreme when it is above the percentile; a value below
the 10th percentile does not count, however unusual. This differs from problem 24.1, where a
low shift counted as much as a high one.
These are the failures with no culprit to point at, because every input involved was merely
somewhat above average. Before you run the tests: one test passes you eight inputs drawn with
no connection to which samples failed. Work out on paper what share of failures it should
return, from one fact: each input is above its own 90th percentile in one future in ten,
independently of the others. Write your working in a comment below. The test holds your
function to that arithmetic, so a pass means your function and your working agree.
Why the figure matters: a failure in which nothing was extreme is a failure of the *design*
rather than of the world. The margin was too thin to absorb an ordinary week, and you fix that
by changing the margin, not by blaming an input.
"""
raise NotImplementedError("problem 24.2")The same check at a desk: python3 -m pytest tests/what_the_model_got_wrong/test_problem_2_extreme.py -m problem
24.3 — A post-mortem on one of yours. No test: it is your history, and nobody else has it.
Find an estimate you or your team made that turned out badly: a fleet that went over its limit early, a budget that overran, a tier that needed replacing sooner than planned. Reconstruct what was assumed at the time, not what is known now.
Then apply this chapter’s question. Was the cause an input that moved, or a structure that was wrong? An input that moved is a wider distribution next time. A structure that was wrong is a quantity nobody had written down, and no amount of sampling would have found it.
A good answer identifies which of the two it was and says what would have caught it. What would show the diagnosis wrong: the input you blamed was inside its declared band at the time, or the quantity you called missing was in the model and merely not looked at. If the answer is that nothing available at the time would have caught it, write that down.
Where to go next
ch20 is the limitation this chapter keeps running into. Re-read it now rather than before, because its argument reads differently once you have seen an attribution rank the inputs a model has without hesitating and say nothing about the one it lacks.
A real post-mortem compares against something that happened: an estate observation.
ch03 sets the disclosure an estate figure must carry: the system,
the window, and when it was observed. That disclosure lets another reader trace the figure to
whoever took it, though not check it.
Appendix E is the web service model in full, the model this chapter’s post-mortem ran on.