DeploymentInteractive lab
Cache eviction simulator
Run the same access trace through LRU, LFU and FIFO
One workload, three eviction policies, one hit-rate chart. Includes the scan pattern that makes LRU look foolish and the skewed one that makes LFU look brilliant.
What this teaches
- Eviction policies
- Hit rate vs cache size
- Scan resistance
The workload
4,000 accessesA small working set, interrupted by a long sequential sweep through cold keys.
Hit rate, same trace
counted, not modelledOn the Scan (hot set + sweep) workload at cache size 32, the best online policy is LFU at 43.0 percent, against an optimal ceiling of 49.0 percent.
OPT is not a policy you can deploy - it evicts whichever key is needed furthest in the future, which requires the future. It is here as the ceiling: the gap between LFU at 43.0% and OPT at 49.0% is how much is left on the table by not knowing what comes next, and an online policy anywhere near it is doing well.
Hit rate against cache size
every point is a full re-run- LRU
- FIFO
- LFU
- OPT
| Cache size | LRU | FIFO | LFU | OPT |
|---|---|---|---|---|
| 2 | 4.2% | 4.2% | 4.5% | 9.8% |
| 4 | 7.8% | 7.7% | 8.6% | 18.1% |
| 8 | 14.9% | 15.3% | 17.3% | 27.7% |
| 12 | 20.5% | 20.6% | 25.1% | 34.2% |
| 16 | 25.9% | 26.4% | 33.2% | 38.4% |
| 24 | 27.9% | 27.9% | 41.6% | 44.0% |
| 32 | 28.1% | 28.1% | 43.0% | 49.0% |
| 48 | 28.1% | 28.1% | 43.0% | 58.3% |
| 64 | 32.0% | 33.1% | 50.6% | 67.3% |
| 96 | 52.8% | 53.8% | 74.0% | 82.3% |
| 128 | 78.6% | 72.8% | 84.7% | 90.0% |
The first 60 accesses
H is a hit, a gap is a missWatch the sweep arrive: LRU and FIFO both fill with keys they will never see again and the strip goes dark for a stretch, while LFU keeps the hot set because a single access never outranks a key seen fifty times.
What is real here, and what is standing in
Real: all four policies are genuine implementations, not models of themselves, and every rate on this page is a count of hits over a count of accesses. LRU really is an LRU, FIFO differs from it by exactly the one line that does not reorder on a hit, and OPT really does look ahead through the whole trace.
Standing in: the trace is synthetic, produced by a seeded generator in this tab, and not a production log. Every object costs exactly one slot, where a real cache has variable object sizes, TTLs, sharding, and admission control - and admission control is precisely how a modern cache such as W-TinyLFU gets scan resistance without giving up on recency, which is the thing this page shows LRU lacking and offers no fix for. LFU here never ages its counters, which is why it looks so strong on the skewed workload and would ossify in production around whatever was hot last month.
Everything on this page runs in your browser. Nothing you type is sent anywhere, there is no account, and it keeps working offline.