What You Actually Buy With a Hit
Last timeWhy the Same Question Keeps Arriving
A hit rate is not a score. It converts into two very different things, a faster average and a much lighter load on whatever sits behind the cache, and the second usually matters more.
Somebody reports that the cache is at ninety per cent and everyone nods. It is
worth slowing down on what that sentence actually promises, because it converts
into two quite different currencies and the conversion rate is not what most
people assume.
The blend
Every request takes one of two paths, and both have a cost you can measure. The
average is therefore a straightforward blend.
A hit costs one millisecond here and a miss costs forty, and the blend is those
two prices weighted by how often each path is taken.
| step | hit rate | hits, at 1 millisecond each | misses, at 40 milliseconds each | average milliseconds per request | what happened |
|---|---|---|---|---|---|
| 1 | 50 per cent | 0.50 of them, so 0.50 | 0.50 of them, so 20.0 | 20.5 | Half the requests are now hits and they contribute half a millisecond. The average is very nearly the miss price, halved. |
| 2 | 90 per cent | 0.90 of them, so 0.90 | 0.10 of them, so 4.0 | 4.9 | Nine requests in ten are hits, and they still account for less than a fifth of the average. |
| 3 | 99 per cent | 0.99 of them, so 0.99 | 0.01 of them, so 0.4 | 1.4 | Only here do the hits finally cost more than the misses, and 0.99 plus 0.4 is 1.39, which a dashboard rounds to 1.4. |
Read down the last column and the early progress looks like the valuable kind.
The first forty percentage points of hit rate bought a saving of fifteen and a
half milliseconds; the last nine bought three and a half. Measured in the
average, improving a mediocre hit rate looks like the work worth doing.
The lesson stops here
6 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents