Sizing and TCO

ch04 · Peak, mean and growth

Builds on ch02 and ch03.

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 number in a demand curve sizes the fleet, and what is a five-year growth rate a claim about?

ch02 established that a workload is a set of quantities, each varying over time. It reduced each to one number: for requests, the peak request rate in the busy hour on day one. This raised two questions: how long a busy period must last to size the fleet, and how the busy hour relates to the daily mean. The growth rate was also reduced to one; this chapter replaces it with a spread.

The material

The busy hour, and what the mean is for

Demand has a shape. It is low overnight, high in the afternoon, and different again on a Tuesday in November. Sizing for the average means sizing for a level that demand passes through twice a day.

The number that sizes the fleet is the busy hour. Or the busy minute, or the busy Tuesday, depending on how long your system takes to fail and how long your users will wait for it to recover. Which of those to use is yours to decide, from your traffic and your tolerance, and the model cannot make the choice for you.

Problem 4.1 asks you to turn a day’s profile and the day’s total into the rate in the busiest hour. The peak-to-mean ratio, the busy hour divided by the daily mean, is a property of the traffic: of when your users arrive. It varies by workload. Quoting another workload’s ratio sizes your system for a daily profile it does not have.

You get your own ratio by watching your own traffic. In ch03’s terms, that is an estate observation: a look at a running system that only you can take and nobody else can check. Nobody has observed this ratio for this service, so the model holds it as an input with a band, marked assumption. An input is not a measured constant. A measured constant belongs to one piece of software at one version. This ratio belongs to your users.

The band is triangular, with a lowest value, a most likely value, and a highest. How likely a value is falls in a straight line from the most likely down to nothing at each end. By definition, the mean is the busy hour divided by this ratio. So if the ratio is right, the mean is right, and the toolkit still calls the model definitional. The model then works out the mean rate from the busy-hour rate:

  peak_to_mean:
    kind: input
    decided: outside
    unit: dimensionless
    label: peak-to-mean ratio
    distribution:
      triangular:
        minimum: 2.0
        likely: 3.5
        maximum: 6.0
    provenance:
      kind: assumption
      source: >-
        ch04 — the busy hour against the daily mean. Triangular,
        and it is a property of your traffic that belongs to the
        estate target: nothing here can measure it
    range: [1.0, 10.0]
  mean_request_rate:
    kind: derived
    unit: request/second
    label: mean request rate at horizon
    formula: peak_request_rate / peak_to_mean

The busy hour sizes the fleet. The mean, times how long the fleet runs, is the total requests served, and that is what a cost per request divides by. ch17 shows that a cost per request quoted against the busy hour comes out several times larger than one quoted against the mean. So the model carries both.

Growth is a bet, and the bet compounds

Growth moves the busy-hour rate at the horizon more than any other input.

This is the book’s first tornado, so here is how to make one.

Take one input and hold every other still at its middle value. Swing that input from the low end of its band to the high end, and record how far the answer moves. That distance is its swing. Do it for every input and sort the bars longest first. They form a funnel, which is where tornado gets its name.

A future is one of many runs of the model’s arithmetic, with every uncertain input set to one of its possible values, picked at random.

The table shows the busy-hour rate at the horizon with each input at its low end, where only one future in ten falls below, and its high end, where only one in ten comes in above. Inputs that do not feed the busy-hour rate, such as the peak-to-mean ratio, leave it unchanged.

InputKindpeak request rate at horizon (request/second) with the input at its low endat its high endSwing
annual growth factorinput17,448103,81486,366
peak request rate, day oneinput25,42966,56041,130
os reserveinput42,56042,5600
peak-to-mean ratioinput42,56042,5600

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

The growth rate is at the top of this tornado, well ahead of the day-one busy-hour rate. That is not a quirk of these numbers. A growth rate is the one input that is raised to a power; everything else is multiplied. Over a five-year horizon, the exponent turns an uncertainty in the rate into a much larger uncertainty in the demand.

That is what a five-year demand forecast looks like when its growth assumption is stated honestly: the busy hour the fleet will have to serve, as a band. The point estimate is somewhere in the middle of it.

The graph has gained two nodes since ch03: the peak-to-mean ratio, and the mean it implies. Three inputs have gained a shape. Click annual growth factor and the band that produced the figure above is written there. Drag its slider and the point moves while the band stays. That is the difference this chapter is about.

The same graph, with the growth rate as a band rather than a figure. Clicking it shows the band.

Which inputs get a band

Click records held, day one in the graph: it keeps a single number and has no band, which is a decision rather than an oversight. You can count how much data you hold today, and a storage system reports it whenever you ask. The busy-hour rate is different: to know it, you must observe your traffic over a period containing the busiest hour, and next quarter’s busiest hour has not happened yet—so it gets a band.

What is uncertain about the records is how fast they grow, and the growth factor carries that for both the rate and the records. The file explains this reasoning in a note beside the value, and the viewer shows it under Details. Giving every input a band is not more careful: a band on a countable number records a doubt you could have removed, and hides that you did not count it.

Compounding an average is not averaging the compounds

There is a specific and expensive error here. Work through it once by hand.

You have a range of plausible growth rates. You want the capacity in five years. There are two things you could compute:

The two are not the same number. Over horizons longer than one year, the second is larger for any spread of growth rates. At one year they are equal, because compounding once is a single multiplication and the average of multiplications is the multiplication by the average. Suppose growth might double the traffic every year or might halve it, each equally likely. The two feel as if they cancel, but the ordinary average, the one problem 4.2 uses, is their sum divided by two. A doubling and a halving average to one and a quarter—growth of a quarter a year. Compound one and a quarter over five years and the traffic roughly triples. Compound each case separately and then average: over five years doubling gives thirty-two times, halving gives a thirty-second, and the average is about sixteen times.

Compounding curves upwards, so the high rates run away faster than the low ones fall. Averaging first flattens the curve and throws that away. The gap widens with the spread and with the horizon, which makes it largest over the five-year plan a fleet gets bought against.

Problem 4.2 is that comparison. Write down which way you think it goes before you run it.

The practical consequence: a capacity plan built by compounding a single “expected” growth rate understates the expected capacity. Not a pessimistic case: the expected one. The plan is optimistic before any of its other assumptions have been questioned.

What a growth rate is a claim about

Nothing in ch03 helps here.

A compression ratio can be measured. A price can be quoted. A growth rate is a claim about the future, and no amount of provenance discipline turns one into a measurement. The best available version is: the last three years, extrapolated, with a band wide enough to admit that the next three might not resemble them. The width of that band is a judgement nobody can check in advance.

This book gives growth a band of the kind called lognormal. In plain words, a lognormal band is lopsided: it runs further above its middle value than below it, and never reaches zero. It fits growth because growth compounds, and the multiplier each year cannot be zero or less, though it can be below one for a shrinking service. The file states the band by its two ends: the values where only one future in ten falls beyond. Stated that way, the band is a sentence you can disagree with: surprised below this, surprised above that. That form is the most useful because a sentence can be argued with and a bare number cannot. It is not a measurement, and the model does not pretend otherwise: the input’s provenance is assumption.

An amount a year, or a share a year

Before you choose a band for the growth rate, choose what kind of growth it is. One question decides it: does demand grow by about the same amount each year, or by about the same share of itself?

The same share is compounding: each year multiplies the grown demand. This is what the book’s model does. The annual growth factor is raised to the power of the count of years. ch02 showed how that works.

The same amount is linear growth: a fixed number of customers or sites added each year, or a contract that adds a set volume. The count of years then multiplies the yearly rise instead of being an exponent.

The two need different inputs, not different values of one input. A compounding rate is a factor with no unit. A linear rate is an amount each year, in the demand’s own unit.

How to tell from your own history: if the yearly increases have stayed about the same size, growth is an amount. If they have grown along with the demand, growth is a share.

A ceiling has a shape of its own, levelling, where demand grows by a share of itself while far from the ceiling and slows as it nears it, as a market fills. A step, when a known event such as a launch or a large customer adds demand at once, remains a refinement the toolkit has no shape for.

The calculator below draws the three shapes compound, linear and levelling from the same starting demand. Adjust the sliders for the growth factor, the amount added each year, the ceiling and the number of years, and watch where one shape overtakes another. Under the chart, the toolkit fills in the formula for each shape with your values.

Three shapes of growth

rate for compound and levelling
rate for linear, in the demand's unit
levelling only: the level it never passes
over: how many years it grows for
compoundstart * rate ** over100 * 1.30 ** 5 = 371rate: the growth factor, each year
linearstart + rate * over100 + 30 * 5 = 250rate: the amount added each year
levellingceiling / (1 + (ceiling / start - 1) * rate ** -over)400 / (1 + (400 / 100 - 1) * 1.30 ** -5) = 221rate: the growth factor, until the ceiling

Every shape starts from 100 today, a round number so the arithmetic is easy to follow. The formulas are the ones the toolkit fills in for a grown node, with each key’s name standing for its value. The amount added each year starts equal to the first year’s compound rise, so those two agree after one year until you move it. Lengthen the years or lower the ceiling to watch levelling flatten.

The shape is a choice about the model’s structure, not a number. No band on the growth rate covers it, because the model’s futures vary the inputs and never the formula.

In a model file, a grown node declares the shape by name: compound, linear, or levelling. Levelling also names its ceiling. The build checks that its rate is the right kind for that shape, and Appendix A lists its keys.

What a demand figure needs before you can size from it

A single peak. “We do forty thousand requests a second at peak” is a rate with no duration. Forty thousand for ten seconds and forty thousand for four hours size the fleet differently. A ten-second burst can wait: requests hold briefly while the fleet works through them. A four-hour peak cannot be deferred: the requests pile up for hours, so your fleet must handle that rate as it arrives.

The wrong thing, measured well. Take a year of per-minute rates and find the level that one minute in twenty is above. That is not the busy hour. If those minutes scatter through the year, each is a brief excursion and the fleet absorbs it; if they bunch into a few afternoons, those afternoons spend hours above the level and your fleet is overloaded. Only when the minutes fall decides whether it is safe to size to that level.

A growth rate with no horizon. A growth rate is not an input until you say for how long. Over one year, it enters the arithmetic once: it multiplies the demand like any other input. Over five years, it is raised to the power of the horizon, and it dominates the tornado shown earlier in this chapter.

What this cannot tell you

What your peak-to-mean ratio is. Nothing in this repository can measure it. It is a property of your traffic, and it belongs to the estate target (ch03). Everything above tells you what to do with one once you have it.

Whether growth will continue. The model extrapolates. Extrapolation is the assumption that the mechanism producing the last three years is still running. A capacity model cannot see the quarter that mechanism stops: a product retired, a customer lost, a competitor won.

Whether the band’s width is calibrated. A growth band stated as surprised below here, surprised above there records the surprise of the model’s author. Whether the width is right can only be checked afterwards, by counting how often actual growth fell outside it. Nothing here does that.

Anything about a shape that changes. Every figure above assumes demand grows without changing its daily profile. A workload that grows by adding a different kind of user grows in a different shape, and the busy hour moves.

Which shape growth takes. The model assumes compounding: each year multiplies the demand. A workload that grows by the same amount each year, or towards a ceiling, needs a different shape, and no band on the growth rate covers it. A ceiling is an estimate of where a market stops, and nothing here measures it. A workload that grows in steps needs a structure the toolkit has no shape for.

Key takeaways

  • The busy hour sizes the fleet; the mean counts the requests. The mean, times how long the fleet runs, is the requests it serves in total, and a cost per request divides by that. The mean is not a level the fleet sits at.

  • The peak-to-mean ratio is an observation of your own traffic. It belongs to your users, so borrowing one from another workload sizes the fleet for a daily profile you do not have. It is an input, not a measured constant, so the model remains definitional.

  • In this model, growth is the one input raised to a power, so it tops the tornado. Over a horizon, an uncertainty in the rate becomes a much larger uncertainty in the demand.

  • Compounding the average growth rate understates the expected capacity. Over any horizon longer than a year, compounding every plausible rate and averaging the results gives a larger answer. The gap grows with the spread and with the horizon.

  • A growth rate is a claim about the future, and no provenance turns it into a measurement. State it as a band, surprised below this, surprised above that, with a horizon attached. A sentence can be argued with; a bare number cannot.

Problems

Four, in tests/peak_mean_and_growth/. The first two have tests. The last two do not, and say why.

4.1 — The busy hour. Given a day’s shape as relative weights and a daily total, return the rate during the busiest hour. The weights do not sum to anything in particular, which is most of the problem.

tests/peak_mean_and_growth/stubs.py · busy_hour_rateyours to edit
def busy_hour_rate(hourly_shape: np.ndarray, daily_total: float) -> float:
    """Problem 4.1 - the number that sizes the fleet is not the daily mean.

    ``hourly_shape`` is twenty-four relative weights describing how a day's demand is distributed:
    a flat day is twenty-four equal numbers, a spiky one is not. ``daily_total`` is how much
    arrives across the whole day, in whatever unit you like.

    Return the **rate during the busiest hour**, in that unit per hour.

    The weights are relative, not absolute, and they do not necessarily sum to anything in
    particular - normalise them. That is most of the problem, and getting it wrong gives an answer
    that is confidently off by whatever the weights happened to add up to.

    The test also checks a flat day, where every hour carries an equal share of the day, so the
    busiest hour is no busier than the average. On a flat day the busy-hour rate and the daily mean
    rate must agree, and a fleet still needs to size to that rate.
    """
    raise NotImplementedError("problem 4.1")

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

4.2 — Compound the average, or average the compounds? Compute both, and find out which is larger and by how much. Predict the direction before you run it. The gap widens with the spread and with the horizon, so it is worst when the plan matters most.

tests/peak_mean_and_growth/stubs.py · growth_gapyours to edit
def growth_gap(t0: float, growth_factors: np.ndarray, years: float) -> tuple[float, float]:
    """Problem 4.2 - compound the average, or average the compounds?

    You have a starting capacity ``t0`` and a bag of plausible annual growth factors
    (``growth_factors``: 1.2 means twenty per cent a year). You want the capacity after ``years``.

    There are two things you could compute—plans usually compute the first:

    * take the ordinary **average** of the growth factors (add them up and divide by how many)
      and compound it over the years from ``t0``;
    * compound **every** growth factor over the years from ``t0``, and take the ordinary average
      of the results.

    Return both, in that order.

    Over one year the two are equal. Over more than one year they differ, and one is always larger.
    Work out which before you run it. The gap widens with the spread of the growth factors and with
    the horizon, so it is largest over the five-year horizon a fleet is bought against.

    The test asserts the order and that the gap is material. It does not tell you the answer; the
    values come from the bag you are handed.
    """
    raise NotImplementedError("problem 4.2")

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

4.3 — What is your growth rate a claim about? No test. This chapter has already said that nobody can check the width of a growth band in advance, and writing a test for it would contradict that on the same page.

Find the growth rate somebody is currently using to plan the system you work on. Then answer three questions about it. What is it extrapolating: users, requests, retained data, or revenue converted into one of those? Over what period was it measured, and is that period long enough to contain the thing that would break it? And what would have to happen for it to be wrong by half, in either direction?

Now write the two ends as a sentence: I would be surprised if it came in under this, and surprised if it came in over that. Say it out loud to whoever owns the plan. The sentence is the deliverable, not the number. A range you are willing to be quoted on is worth more than a point estimate nobody will defend.

A good answer names the mechanism, not just the trend, and its band is wide enough to be uncomfortable. If the band is narrow and comfortable, you have described the last three years rather than the next three.

4.4 — An amount or a share? No test. The history is yours, and nothing here has seen it.

Take the demand history of a system you run, the longer the better. Work out each year’s increase. Say whether the increases have stayed about the same size or grown with the demand, and so which shape the model should use.

A good answer names the mechanism behind the growth, not only the pattern. It is falsified if the increases are growing while you chose an amount, or flat while you chose a share; or if the period you looked at is too short to tell the two apart.

Where to go next

ch05 begins Part II, and changes the subject from how much demand there is to what happens to a system when it arrives.

ch13 shows how the band in this chapter’s second figure was produced.

ch19 shows what to do about growth at the top of the tornado: it cannot be measured, so it has to be decided.

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