Definition · Working setThe working set is the portion of the data that the traffic touches over a window. A workload with hot fraction f and hot share s has f of its bytes taking s of its reads; caching a fraction c of the data gives a hit rate h(c), and the memory needed for a target h is the dataset times the c that reaches it.
The two numbers f and s are what makes caching work at all. If reads were spread evenly over the data, caching c of it would buy c of the hits and a cache would be exactly as useful as it was large — which is to say, not useful, because you cannot afford a cache the size of the data. Skew is the whole business case.
inside the hot region c ≤ f
h(c) = s · c/f
past the knee c > f
h(c) = s + (1 − s) · (c − f)/(1 − f)
inverted, for a target h:
h ≤ s : c = f · h/s
h > s : c = f + (1 − f) · (h − s)/(1 − s)
Both branches are straight lines and they meet at (f, s), which is the knee. The first has slope s/f — here 9, so each point of cached data buys nine points of hit rate — and the second has slope (1−s)/(1−f), here 1/9. A factor of eighty-one between the price of a hit before the knee and after it, and it changes at a single point.
Example · Five terabytes of timelines, eighty percent wantedWith f = 10% and s = 90%, a target of 80% is inside the hot region, so c = 0.1 · 80/90 = 4/45, which is 8.89% of the data, or 444.44 GB. Less than half a terabyte of memory serves four reads in five out of a five-terabyte store. That ratio — and not the absolute figure — is why caches exist.
What the last five points cost
Caching the entire hot region costs 500 GB and gives a hit rate of 9/10. Ask for 95% instead and the memory needed is 11/20 of the data, 2.75 TB. The first ninety points of hit rate cost half a terabyte; the next five cost more than four times that again, because they are bought from a region where reads are spread thinly over a lot of bytes.
This is the shape of every cache-sizing conversation worth having. The target hit rate is a choice, it has a price, and the price is wildly non-linear in the target. A team that asks for “99%” because it sounds rigorous has usually asked for the whole dataset in memory without noticing; a team that reads the knee off the curve first asks for a number it can pay for.
What the model assumes
Two things, and both are visible in the shape of the curve. Within the hot region every key is equally popular, and within the cold region every key is equally popular — which is what makes each branch a straight line, and it is not true of any real workload. And the split into two regions is itself a simplification of a smooth popularity curve. The model is right about the two things this lesson claims — that a small cache buys a large hit rate, and that there is a knee — and it is an approximation about everything else.
The other assumption is quieter: f and s were measured over some window and are being used as though they were properties of the system. They move. The honest report says which window they came from, exactly as a read/write ratio does, and treats them as ranged factors when they are carried into a product.
“Cache Size and Hit Rate”, on Caching and Hit Rates, replaces the stated pair with a Zipf popularity exponent, from which the same curve is derived rather than asserted — and the knee softens into a genuine curve with diminishing returns everywhere. This lesson is the version that can be done on an envelope, and it gets the two structural facts right.