tools / cache-hit-ratio
Cache Hit Ratio Calculator
Effective latency from hit ratio, hit cost and miss cost.
Effective latency
Time spent on misses
+1 point of hit ratio
Key facts
| Formula | t = h · t_hit + (1 − h) · t_miss |
|---|---|
| t_miss | The full cost of a miss: lookup plus fetch from the slower tier |
| Misses dominate | At 95% hits and a 50× miss penalty, misses are 72% of total time |
| Think in miss ratio | Going from 95% to 99% hits cuts misses 5× — not "4% better" |
Worked example
A cache answers in 1 ms. A miss goes to a database: 50 ms in total.
95% hits: 0.95 × 1 + 0.05 × 50 = 3.45 ms 99% hits: 0.99 × 1 + 0.01 × 50 = 1.49 ms
Four extra points of hit ratio more than halve the average. The 5% of misses were costing more than all the hits put together.
Averages hide the misses
Effective latency is an average. Every miss still takes the full 50 ms, so with 5% misses, p99 is a miss. If you care about tail latency, the hit ratio sets which percentile first lands on the slow path.
FAQs
Does this work for multi-level caches?
Yes — apply it from the bottom up. The effective latency of the lower level becomes the miss cost of the level above.
Why did my hit ratio drop after a deploy?
A fresh process starts with a cold cache. Hit ratio climbs as it warms; plan for slower responses and more backend load right after restarts.
Is a higher hit ratio always worth it?
Each extra point costs more memory than the last, since remaining misses are rarer keys. Stop when the latency gain no longer justifies the memory.