Learn
Lesson · Caching and Hit Rates · The miss rate

Hit Rate and Backend Load

A cache is described by its hit rate and judged by its miss rate. The backend never sees h; it sees 1 − h, multiplied by the arrival rate. So the interesting number is the one nobody quotes, and moving a cache from ninety to ninety-nine per cent is a tenfold cut in what arrives rather than a nine-point improvement.

backend load = (1 − h)·λ the cache absorbs hλ; the backend sees the rest λ = 10 000 rps, μ = 2 000 rps h = 90% 1 − h = 1/10 → 1 000 rps ρ = 1/2 h = 95% 1 − h = 1/20 → 500 rps ρ = 1/4 half the load h = 99% 1 − h = 1/100 → 100 rps ρ = 1/20 a tenth of it
The hit rate, converted into the number the backend sees

Core ideas

What this lesson establishes

One multiplication, and two habits of reading it. The multiplication is easy; the habits are what make the answer feel wrong the first time.

1

The backend is a function of 1 − h

Requests arrive at λ. A fraction h is served from the cache and never leaves it; the rest, (1 − h)λ, is forwarded. At λ = 10 000 requests a second and h = 90% the cache absorbs 9 000 and the backend receives 1 000. Every sentence about the backend — its load, its utilisation, its wait, its bill — is a sentence about 1 − h.

2

A gain in h is a ratio of miss rates, not a difference

From 90% to 95% the miss rate goes 1/10 → 1/20, so the backend load is halved. From 90% to 99% it goes 1/10 → 1/100, so the load is divided by ten. Five points and nine points look comparable written down and are not: what matters is the ratio of the two small numbers, not the gap between the two large ones.

3

What moved is the backend’s ρ

Backend load divided by backend capacity is the utilisation of Queues and Utilisation. At μ = 2 000 requests a second, 1 000 in means ρ = 1/2 and 100 in means ρ = 1/20. A cache is a utilisation control, and the wait it buys is not proportional to the load it removes.

The material

The miss rate, the backend load, and the utilisation it leaves

Why the same improvement reads as small on one side of the cache and enormous on the other.

Definition · Hit rate and miss rate

For a stream of requests arriving at rate λ, the hit rate h is the fraction served from the cache and the miss rate 1 − h is the fraction forwarded. The backend load is (1 − h)λ, in the same units as λ.

The two rates are one number written two ways. Which one you write down decides what the sentence is about: h is about the cache, 1 − h is about everything behind it.

There is no model in that definition and no assumption to argue with. It is a split of a rate into two parts, and it is exact whenever the hit rate is measured over the same window as the arrival rate. What it is not is stable: h is a property of the workload and the cache together, and a change in either moves it.

Example · Ten thousand requests a second at a ninety per cent hit rate

λ = 10 000 rps and h = 90%. The cache absorbs (9/10)(10 000) = 9 000 rps and the backend receives (1/10)(10 000) = 1 000 rps. Against a backend that can serve μ = 2 000 rps that is ρ = 1 000/2 000 = 1/2, so the backend is busy half the time.

One more nine is a factor, not a gain

Take the same λ and improve the cache. At h = 95% the backend receives (1/20)(10 000) = 500 rps: the hit rate went up by five points and the backend’s work halved. At h = 99% it receives 100 rps, a tenth of what it received at 90%. Nothing about the backend improved by nine per cent.

backend at h₂ (1 − h₂)λ 1 − h₂ ─────────────── = ───────── = ─────── backend at h₁ (1 − h₁)λ 1 − h₁ h₁ = 90%, h₂ = 95% (1/20)/(1/10) = 1/2 half the load h₁ = 90%, h₂ = 99% (1/100)/(1/10) = 1/10 a tenth of the load

The λ cancels, which is why the factor is a property of the two hit rates alone. It is also why the same percentage point is worth wildly different amounts at different places on the scale: 50% to 51% divides the backend load by 50/49, about two per cent, while 98% to 99% divides it by two.

Example · The same cache, four ways

At λ = 10 000 rps into a backend of μ = 2 000 rps: h = 90% leaves 1 000 rps and ρ = 1/2; h = 95% leaves 500 rps and ρ = 1/4; h = 99% leaves 100 rps and ρ = 1/20; h = 99.9% leaves 10 rps and ρ = 1/200. The hit rates in that list are nearly the same number. The utilisations differ by a factor of a hundred.

The utilisation is the thing you were actually buying

Backend load on its own does not tell you what the backend feels. “The M/M/1 Queue” gives the mean wait at a rational utilisation as W = 1/(μ − λ), and on these four rows that is 1.00 ms, 0.67 ms, 0.53 ms and 0.50 ms. Notice how little the last two moved: past the knee, further hit rate buys almost nothing, because the queue was already nearly empty. “The Knee: Response Time vs Utilisation” is the curve that says which side of it you are on.

So a cache is worth the most exactly where the backend is worst. Going from ρ = 0.95 to ρ = 0.5 is the difference between a system that falls over and one that does not; going from ρ = 0.05 to ρ = 0.005 is the difference between two numbers nobody can feel. The hit rate is the lever and the utilisation is the load, and it is the load you should be looking at.

Two cautions before the lab. First, (1 − h)λ is the average backend rate, and the backend’s bad moments are not averages — a hot key expiring sends a burst through that this formula does not see, which is what Cache Stampedes is for. Second, the hit rate is measured, not chosen: writing 99% into a capacity plan is a forecast about a workload, and it deserves the error bar Capacity Estimation taught you to carry.

Interactive

A hit rate is a statement about the backend

(1 − h)λ is what arrives there, and ρ is what it does

Backend load is the miss rate(1 − h)λ, and the ρ it leaves the backend at
hits, absorbedmisses, forwardedbackend capacity

Method

Converting a hit rate into a backend number

Four lines, and the first one is the whole discipline: write down the miss rate before anything else.

1

Write the miss rate, not the hit rate

h = 99% becomes 1 − h = 1/100. Do it as a fraction rather than a decimal: 1/100 invites you to compare it with 1/10, and 0.01 invites you to compare it with 0.10, which reads as a small difference.

2

Multiply by the arrival rate

(1 − h)λ is the backend load in the units λ came in. Keep the units visible — requests per second, not just a number — because the next step divides it by a capacity that must be in the same units.

3

Divide by the backend’s capacity

ρ = (1 − h)λ/μ is what the backend is actually running at. If ρ ≥ 1 the cache has not saved it: the backlog grows without bound and there is no mean wait to quote.

4

Quote the change as a ratio

Two hit rates give a factor (1 − h₂)/(1 − h₁), and that factor is the honest way to report a cache improvement. “We halved the database load” is a claim someone can check; “we improved the hit rate by five per cent” is a claim about the wrong side of the cache.

Miss rates and backend loads

Score 0 / 0

λ = 10 000 rps, μ = 2 000 rps: what one more nine buys

The arithmetic is one multiplication and one division. What is worth watching is how the four columns move at different speeds.

λ = 10 000 rps arriving, backend capacity μ = 2 000 rps h 1 − h backend (1 − h)λ ρ = load/μ W = 1/(μ − load) 90% 1/10 1 000 rps 1/2 1.00 ms 95% 1/20 500 rps 1/4 0.67 ms 99% 1/100 100 rps 1/20 0.53 ms 99.9% 1/1000 10 rps 1/200 0.50 ms 90% → 95% (1/20)/(1/10) = 1/2 the backend does HALF the work 90% → 99% (1/100)/(1/10) = 1/10 the backend does a TENTH of it the hit rate moved by 9 points; the backend load moved by a factor of 10

Read the third column and the fifth column together. Between 90% and 99% the backend load falls by a factor of ten and the mean wait falls by about half: the load is linear in the miss rate and the wait is not. That is the whole reason to compute both.

For a faded rehearsal, take λ = 40 000 rps into a backend of μ = 1 000 rps. The supplied first move is that the backend is overloaded at h = 95%: check that, then find the smallest hit rate in tenths of a per cent that puts ρ below 1/2, and state the factor by which the load fell relative to 95%. Run the lab at your answer before opening the quiz.

The lab recomputes every row from (1 − h)λ as you move the sliders, and prints the backend’s wait from the M/M/1 result of Queues and Utilisation beside it. Drag the hit rate from 90% to 99% and watch which of the four numbers actually moves.

Common mistakes

1
Reading a hit-rate gain as a percentage gain“We improved the hit rate by five per cent” says nothing about the backend. From 90% to 95% the backend’s work halves; from 50% to 55% it falls by a ninth. The same five points, two different factors, because the quantity that moved is 1 − h and the factor is the ratio of the two miss rates.
2
Quoting h in a sentence that is about the backendA capacity plan, a database size, an egress bill and a page about database CPU are all statements about 1 − h. Writing h there is not wrong, it is unreadable: 99.9% and 99% look like the same number and differ by a factor of ten in every consequence.
3
Assuming the wait falls in step with the loadAt μ = 2 000 rps, taking the backend from 1 000 rps to 100 rps cuts the load by ten and the mean wait from 1.00 ms to 0.53 ms. Waiting is a function of ρ and it is nearly flat once ρ is small, so most of what a cache buys in latency is bought before the last nine.

Check your understanding

✓
Finish when 1 − h is the number you reach for without being asked.

You should be able to convert a hit rate and an arrival rate into backend requests per second, divide by a capacity to get ρ, and state a cache improvement as the factor by which the backend load fell rather than as a change in percentage points.

Note: Backend load is only half of what a cache changes. The other half is what a single request experiences, and there the hit rate stops being a multiplier and becomes a weight: “Average Latency under a Cache” computes the mean as an expectation over two outcomes, and then shows that the percentile ignores the mean entirely.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.