System Designestimator

Cache hit rate estimator

How big does a cache need to be? It depends less on the data size than on how skewed the requests are. When a few keys take most of the traffic, a cache holding 1% of the keys can answer most requests. When traffic is flat, it cannot.

Requests served from cache

A cache holding 1% of the keys serves 58.5% of requests with LRU, so the origin sees 2,074/s instead of 5,000/s.

LRU hit rate58.5%Che’s approximation
0%20%40%60%80%100%0%1%2%3%4%5%Cache size, % of all keysHit rate10K keys
Ideal (most popular keys)LRU (Che)
Ideal hit rate68%Always holds the most popular keys
Mean latency (LRU)17.1 ms13.3 ms ideal · 40 ms with no cache
Origin requests (LRU)2,074/s1,600/s ideal · 5,000/s with no cache

Your traffic and cache

Everything a request could ask for: users, products, pages.

0 is uniform. Around 1 is typical for web traffic. Higher means a few keys take most requests.

Size in

A size above the key count is treated as the key count.

Ideal against LRU

Hit rate, latency and origin load for an ideal cache and for LRU
MeasureIdealLRU
Hit rate68%58.51%
Miss rate32%41.49%
Mean latency13.3 ms17.1 ms
Origin requests1,600/s2,074/s

The cache holds 10,000 of 1,000,000 keys (1%). The most popular 1% of keys receive 68% of requests. LRU gives up 9.5 points of hit rate to the ideal cache because it keeps recently used keys, not the most popular ones. Mean latency is the cache lookup plus the miss rate times the origin latency, since every request pays for the lookup.

What the model leaves out

Requests are treated as independent draws with fixed popularity. Real traffic has bursts and trends that favour LRU, and scans and one-off keys that hurt it. Items are the same size, nothing expires, and writes do not invalidate entries. Use the numbers to compare options, then measure.

What it shows

A cache works when a few keys take most of the traffic. Then a cache holding 1% of the keys can answer most requests. When traffic is flat, it cannot.

Set the number of keys, how skewed the requests are and the cache size. The tool gives the hit rate of an ideal cache and of an LRU cache, then the mean latency and the load left on the origin. It is a model, not a measurement.

How to read it

  • Skew s is the Zipf exponent. 0 means every key is equally likely. Larger values put more traffic on the top keys.
  • Ideal hit rate is the share of requests that go to the top k keys, for a cache of k keys. It always holds the most popular keys.
  • LRU hit rate uses Che’s approximation. It is the share of requests that find their key among those used most recently.
  • Mean latency is the cache lookup time plus the miss rate times the origin time. Origin requests per second are the miss rate times the request rate.
  • On the chart, the solid line is the ideal cache and the dashed line is LRU. The marker is your cache size. The curve flattens as the cache grows.

Questions

Why is LRU below the ideal hit rate?

LRU keeps what was used recently, not what is used most. A key that was requested once a moment ago pushes out a popular key that was idle for a while. Frequency-aware policies close part of that gap.

Is Che’s approximation exact?

No. It is an approximation that works well for independent requests, and the tool’s tests check it against a simulated LRU cache. Real traffic with bursts or scans can land above or below it.

What value of s should I use?

Fit it to your own request counts if you can. Breslau et al. showed that web request counts follow a Zipf-like curve, but the exponent differs between traces and products. Try 0.8, 1 and 1.2 and see how much the answer moves.

Why does a bigger cache help less and less?

Each extra key is less popular than the last one added, so it answers fewer requests. Past the point where the curve flattens, more memory buys little.

Does this include cache misses from expiry and invalidation?

No. It assumes fixed popularity, equal-sized items, no TTL and no writes. Expiry and invalidation only lower the real hit rate, so treat the figure as an upper estimate for the traffic shape.

Learn it properly

Sources

Explore further

  • Caffeine simulatorReplays real cache traces through LRU, LFU and newer eviction policies to compare hit rates.

Last updated

More tools

All tools

Your first senior-level
lesson is free.

Choose a course, open a free lesson, and explore an idea you’ve wanted to understand.