Sizing and TCO

ch19 · Which input to go and measure

Builds on ch13.

A video summary of this chapter, generated from the page by an AI tool (how it was made). The page is the authority; the video needs a network connection.

The question

Which input should you go and measure first, and how would the model tell you?

An interval describes a problem, but it does not tell you what to do about it. You can measure an input, decide it, or design around it — and before any of those, you need to know which input the answer rests on. Everything here works on a model that has already been sampled, so it needs ch13 behind it rather than the chapter before.

The material

More samples never help

The instinct is to run more samples. ch14 said why that fails: a wide interval is not sampling noise. The interval is a property of the model’s inputs. More draws locate it more precisely. They do not narrow it.

Three things narrow an interval, each aimed at one input.

All three are work. The question is which input to spend it on. The answer is not obvious: on some outputs one input carries most of the interval, and on others no single input carries much of it. The tables further down show both.

Swing one thing at a time

Each bar swings one input across the middle eighty per cent of its own distribution, with everything else held still. Problem 19.1 builds this chart, against the host count rather than the total.

The swing comes from the input’s declared distribution, not from its slider range. Otherwise an input the modeller gave a generous slider would get a long bar for free, and the chart would measure the modeller’s choice of slider rather than the model.

The ordering tells you what to measure first. A tornado swings one input at a time, so it cannot show inputs moving together or effects that only appear when two inputs move at once.

What the widest bars have in common

InputKindresidence time in seconds at its p10at its p90Swing
annual growth factorinput0.01780.6540.636
peak request rate, day oneinput0.02120.6540.632
CPU time per requestinput0.02050.1010.0805

Source — web_service-reference · the model to explore; each input with a range has a slider

Three figures on this page swing one input at a time. Look at what is at the top of each.

The five-year total: the top bar is the number of engineers, then licence per core, salary, and host price.

The retention store (the observability model’s stored metrics and logs): the top bar is annual growth, and extra accidental label values are a close second. Growth is raised to the power of the horizon. Extra accidental label values feed label cardinality, a product of uncertain counts, and that uncertainty compounds (ch08).

The residence time (the web service): the day-one busy-hour rate and annual growth tie at the top. CPU time per request is a distant third, and no other input moves it. These inputs meet in a division by what is left of the system (ch06). As what is left gets small, each step of load costs more than the one before, so an input that adds load swings the answer a long way.

Two of these figures share a pattern: the widest bar is somewhere the model is not linear. An exponent, a product of uncertain things, a division by a small remainder. The retention store and the residence time both show this. Inputs that are only multiplied by constants, or added, hardly move anything, however uncertain they are.

Growth is raised to a power, so you would expect the five-year total to follow the same pattern. ch04’s tornado swings the busy-hour request rate at the horizon, before any fleet has been chosen, and growth tops it, well ahead of the next input, the day-one busy hour. But growth is not on the five-year total’s chart, and it cannot be.

The cost chain starts at hosts in the fleet, which is a decision somebody took, and a decision has no distribution. The exponent left the cost chain when the fleet was chosen. What remains downstream is a bill of materials, and in a bill of materials the largest line wins: engineers, licence per core, salary, host price. ch15 found this same ordering for the running cost.

A tornado is about the output you point it at, and pinning a decision can remove the dominant input from everything downstream of it. ch04’s tornado and the five-year total’s chart are both right. They answer different questions. The cost question has a boring answer because the interesting one was settled before it was asked.

The correlation the chart cannot show

ch14 sampled both reference models twice: once with their declared correlations and once without. Declaring that two inputs move together widened every interval it measured. A tornado cannot show that, because each bar moves one input and a correlation is a statement about two.

The tornado and the interval answer different questions. The tornado ranks inputs by how far each moves the answer alone, while the interval, sampled with correlations, says what the model currently believes. An input with a short bar that is strongly correlated with a long one is still worth attention, and the tornado will not tell you so.

What one-at-a-time misses

Swing input A alone. Swing B alone. Swing both. If the model were additive in them, the third would be the sum of the first two.

Where two inputs meet in a product, it is in general not. In the web service, growth raised to the horizon multiplies the day-one busy hour. In the observability model, the label value counts multiply each other into cardinality. In the five-year total, the number of engineers multiplies what each is paid. Problem 19.2 measures the gap on two pairs from the web service: one that meets in a product and one that meets only in a sum. Where inputs meet only in a sum, as the lines of the five-year total do, the swings do add.

So a tornado’s bars do not add up to the interval, and they are not a decomposition of it. They are a ranking, and that is all they are. The chart invites you to read the bar lengths as shares of the variance, and that is a mistake. A variance-based decomposition would answer that question. It is not in this toolkit. NEXT_STEPS.md in the repository lists it as work left to do.

What the measurement would be worth

A ranking is not a quantity. Whoever approves a measurement will ask what it would buy. That can be computed: take one uncertain input and pin it, as if measured perfectly, then re-sample the whole model. What comes back is the interval the model would report if that one thing were known.

A perfect measurement can land anywhere in the input’s band, and you do not know where until you take it. Each input is pinned three times: at the low end, middle, and high end — the same two ends the tornado swings it between. Each column is the share of today’s interval that the pin removes, and a negative share means the interval came back wider. Here it is against the five-year total:

If this were known exactlyRemoved, if found at its low endat its middleat its high end
engineers, full-time equivalent24%18%8%
licence per core15%15%15%
fully loaded salary18%11%1%
host price12%11%10%
network price per host2%2%2%
support rate2%1%−1%
electricity price1%1%1%
host power0%0%0%
PUE0%0%0%
every one of them100%
the rows above total 60%and are not shares of anything

Source — value-of-information · sizing.evaluate

No single input removes much of the five-year total’s interval, wherever it lands. The four at the top are engineers, licence per core, salary, and host price. Everything below removes almost nothing in any column, the electricity price included.

Licence per core removes the same share wherever it lands: it is only multiplied by the fleet’s fixed count of cores and added to the other lines. Engineers and salary remove more if found low than high because they multiply each other. An input whose row is small in all three columns is not worth measuring, and you can tell that before spending anything.

No real measurement is perfect. A real one leaves a standard error behind, that error propagates like any other (ch03), and the table does not include it.

Now the same experiment against the host count, which is the question ch12 asked. The answer has the opposite shape:

If this were known exactlyRemoved, if found at its low endat its middleat its high end
annual growth factor89%72%32%
share of records touched in a busy hour12%10%−19%
peak request rate, day one13%10%−13%
CPU time per request11%6%−7%
index overhead1%0%0%
os reserve2%0%−1%
record compression ratio0%0%0%
every one of them100%
the rows above total 99%and are not shares of anything

Source — value-of-information · sizing.evaluate

One input, annual growth, dominates every column. Where it lands matters most: found low, it would remove most of the interval; found high, far less.

Three inputs widen the host count’s interval when found at the high end of their bands: the day-one busy-hour rate, the share of records touched in a busy hour, and CPU time per request. Each multiplies the demand, so a high value scales up the spread that every other input contributes.

Growth belongs to no target and cannot be measured at all (ch04). The table will keep pointing at it. The only thing you can do with it is decide it, by policy, and accept the flexibility that costs.

And on the observability model, where the answer has a third shape:

If this were known exactlyRemoved, if found at its low endat its middleat its high end
annual growth69%45%0%
extra accidental label values56%44%0%
different endpoint label values39%8%−41%
request rate13%5%−8%
lines per request12%5%−7%
different status label values22%4%−25%
bytes per sample, compressed0%0%0%
bytes per log line, compressed0%0%0%
every one of them100%
the rows above total 111%and are not shares of anything

Source — value-of-information · sizing.evaluate

In the retention store, annual growth and extra accidental label values almost tie in the middle column. The ends separate them: found low, growth removes more; found high, neither removes anything.

The same number is not the same decision. Extra accidental label values are a count you could query from your own system this afternoon. Growth is a forecast again, with the same answer: decide it.

The measured constants buy nothing. The record compression ratio in the host count’s table, and bytes per sample and bytes per log line in the retention store’s, were measured over a declared corpus, with a standard error, by the most careful machinery in this book. Pin any of them at either end of its band or at its middle, and the interval does not move.

Their values matter, because they scale the answer. Their uncertainty is not what the answer rests on. Measuring them again, better, would produce a nicer provenance and the same interval.

And the rows do not add up. The middle column of the five-year total’s table comes to well under the whole interval, and the retention store’s to more than the whole. The rows are not shares of anything. Uncertainty in a chain of multiplications does not divide between the inputs.

Turning the ranking into a plan

The point of a sensitivity analysis is to change something, so it ends in a plan. Take the input at the top and measure it, decide it, or design around it. Then re-run the model. The tornado will have a different input at the top. That is what progress looks like here: not a narrower interval on the same chart, but a different chart.

What this cannot tell you

How much the interval would narrow if you measured it in practice. The tables pin an input exactly, at three places in its band. A real measurement is not exact: it leaves a standard error behind, and how large that error would be is not knowable before doing the work. Nor is where it will land, until you take it. For an input that multiplies others, where it lands decides whether the interval narrows a lot, a little, or widens. So the tables show what a perfect measurement would do, but how close you get to it depends on the measurement you can take.

Anything about interactions. One at a time, by construction. Where two inputs multiply, moving both together can move the answer further than their two bars added up. How big the gap is depends on the two bands. It is small when either band is narrow. It grows when both bands are wide and reach further above their middle value than below it, as when a growth rate is raised to a power and compounding stretches its high end. An input whose effect appears only in combination with another gets a short bar and can still be the thing that sinks you.

Anything about correlated inputs. As above: a bar is one input and a correlation is two.

Whether the input can be measured at all. Against the host count, and again in the observability model, the input worth most is a growth rate. That is a claim about the future, and it belongs to no target (ch04). The chart will keep pointing at it, and the response is to decide it rather than measure it.

Whether the model has the right inputs. An input that is not there has no bar. A tornado of a model missing a cost line is a confident ranking of the wrong list. ch20 · The missing node.

Key takeaways

  • Three things narrow an interval: measure an input, decide it, or design around it. More samples locate the interval. They never shrink it.

  • A tornado ranks inputs by how far the answer moves when each one swings alone. The ordering answers what should I measure first; it swings one input at a time, so it cannot show inputs moving together.

  • The widest bar is where the model is not linear. An exponent, a product of uncertain things, a division by a small remainder. Pinning a decision can remove the dominant input from everything downstream of it.

  • The bars are a ranking, not a decomposition. They do not add up to the interval, they cannot show a correlation, and an input whose effect appears only in combination gets a short bar and can still sink you.

  • What a perfect measurement of an input would buy can be computed before you spend anything. Pin the input at the low end, middle and high end of its band and re-sample to read how much of the interval each pin removes. An input that multiplies others, found high, can leave the interval wider. Often the input at the top is a growth rate, and the only thing to do with a growth rate is decide it.

Problems

Three, in tests/which_input_is_the_answer/. The first two have tests. The last does not, and says why.

19.1 — Build the chart. Build the tornado for the number of hosts the model recommends. The test hands you two things: each input’s band, which is the middle eighty per cent of its declared distribution, and a way to ask the model for the host count with any inputs held. The band is not the slider range, so every bar answers the same question. Return one bar per input, as the input’s name and the bar’s length, longest first.

tests/which_input_is_the_answer/stubs.py · tornadoyours to edit
def tornado(
    swings: dict[str, tuple[float, float]], output_at: Callable[[dict[str, float]], float]
) -> list[tuple[str, float]]:
    """Problem 19.1 - build the chart yourself.

    ``swings`` maps each uncertain input of the web service model to the two ends of its band:
    its tenth and its ninetieth percentile, as its declared distribution gives them. The swing
    comes from the distribution rather than from the slider range, so that every bar is answering
    the same question - "across the middle eighty per cent of what this input could be" - and an
    input somebody gave a wide slider to does not get a long bar for free.

    ``output_at(held)`` is the model at a point. Hand it a dictionary of input names and values
    and it returns the number of hosts the model recommends with those inputs held there and
    everything else at its point value. ``output_at({})`` is the point estimate itself.

    Return a list of ``(input_name, span)`` pairs, sorted with the largest span first: for each
    input in ``swings``, how far the output moves when that input alone is swung from one end of
    its band to the other. Two calls per input; you do not have to sample.

    The test builds both arguments from the model file and the reference scenario. It leaves out
    anything the scenario has already pinned, anything the model cannot evaluate, and the
    measured constants: their uncertainty is a standard error rather than a band, and the build
    swings them by a different rule.
    """
    raise NotImplementedError("problem 19.1")

The same check at a desk: python3 -m pytest tests/which_input_is_the_answer/test_problem_1_tornado.py -m problem

19.2 — What one-at-a-time misses. Move two inputs separately, then together, and measure the difference: how far the joint move is from the two separate moves added up, as a fraction of those two. The test hands you the two bands and the same way of asking the model as in problem 19.1. It runs your function on two pairs from the web service: the annual growth factor and the index overhead, which meet in a product, and the electricity price and the number of engineers, which meet only in a sum. The second pair checks that your function finds nothing where there is nothing to find.

tests/which_input_is_the_answer/stubs.py · interaction_gapyours to edit
def interaction_gap(
    output_at: Callable[[dict[str, float]], float], swings: dict[str, tuple[float, float]]
) -> float:
    """Problem 19.2 - what one-at-a-time misses.

    ``swings`` holds exactly two inputs, each mapped to the two ends of its band, its tenth and
    its ninetieth percentile. ``output_at(held)`` returns one output of the model with the named
    inputs held at the given values and everything else at its point value, as in problem 19.1.

    Swing the first input alone from the low end of its band to the high end and record the
    change in the output. Swing the second alone and record that. Then swing **both together**
    and record that.

    Return the difference between the change when both move and the sum of the two individual
    changes, as a fraction of the sum of the two individual changes. Dividing by the sum of the
    separate changes, not by the joint change, shows how far the tornado's bars, added up, miss
    the joint move.

    Zero means the two inputs do not interact here and the tornado's bars can be added up. Anything
    else means they do, and a chart of one-at-a-time swings is understating - or overstating -
    what happens when the world moves two things at once.

    When you swing one input alone, the other is not included in the dictionary you pass to
    ``output_at``, so it is held at its point value.

    The test names the two pairs: one that meets in a product on the way to the raw data, and one
    that meets in a sum on the way to the annual running cost. Where two inputs meet in a product,
    a gap usually shows, because a product is not additive in its factors - which is the point, and
    is why a tornado is a guide to what to measure rather than a decomposition of the answer.
    """
    raise NotImplementedError("problem 19.2")

The same check at a desk: python3 -m pytest tests/which_input_is_the_answer/test_problem_2_interaction.py -m problem

19.3 — Which input yours rests on. No test: the ranges are the ones you would defend, and only you can say what those are.

Before computing anything, ask two colleagues which input they think the answer is most sensitive to. Write down their answers. Then work it out: swing each input across the range you would defend, one at a time, and see which moves the result most.

The disagreement is the point. In this book’s web service model, growth dominates the ranking whenever the output is a size and disappears whenever it is a bill, where people and licences come first. In yours the top may be a price, a ratio or a constant nobody has measured. Being wrong about where the sensitivity is means measuring the wrong thing next.

A good answer has a ranking, and a note of where it differed from what people expected. If it matched everybody’s intuition exactly, check that your ranges are the ones you would defend rather than the ones that were easy to write.

Where to go next

ch20 is the input that has no bar because it is not in the model, and the one error nothing in this book can rank.

By Chris Snow, in collaboration with Claude (Anthropic) · Prose and figures: CC BY-NC 4.0 · Code and models: Apache 2.0