Cache Hit Ratio Calculator

🔒 Processed 100% in your browser — nothing is uploaded

About this tool

Every cache answer to the same question: of all the requests that came in, how many were served without touching the slower thing behind the cache? That fraction — hits divided by hits plus misses — is the cache hit ratio, and it decides whether your Redis layer is a shield or a decoration, whether your CDN bill makes sense, and whether the CPU in your laptop spends its cycles computing or waiting for RAM. This calculator computes the ratio itself, then follows it into the three places it matters: average access time, backend offload, and cache sizing.

The Ratio tab takes the numbers every cache already counts — hits and misses from Redis INFO keyspace_hits/keyspace_misses, a CDN dashboard's edge-hit percentage, or two counters you add to your own memoization wrapper — and gives the hit and miss ratios. If you only know total traffic and a ratio, a mode switch works from that direction instead. The Speed tab turns the ratio into time with the textbook AMAT formula from computer architecture classes: hit time × ratio + miss penalty × (1 − ratio). CPU people know it as L1 ≈ 1 ns versus RAM ≈ 100 ns; backend people know it as Redis ≈ 1 ms versus Postgres ≈ 20 ms. Same formula, different constants — the tab accepts the miss penalty in ns or ms, reports the effective average latency and the speedup over no cache, and shows the marginal effect of one more percentage point of hit ratio.

The Offload tab converts the ratio into what the backend never has to do: daily requests times hit ratio is requests your database, API or origin server never sees, which is also the percentage by which the cache reduces backend load, and — multiplied by per-request latency or cost — the waiting time and money avoided. The Sizing tab works from the other end: average object size times object count is the dataset, cache capacity divided by it is the share that fits, and in the worst case of perfectly uniform traffic that share is the ceiling on your hit ratio; it also reverse-solves the capacity needed to hold enough objects for a target ratio.

Real traffic is not uniform, which is why caches work at all. Request popularity follows a Zipf-like distribution — a few hot keys take most of the traffic — so a cache holding a small fraction of the dataset can still deliver a 90% hit ratio, as long as an eviction policy like LRU keeps the hot head resident. The flip side is diminishing returns: pushing from 50% to 85% mostly means caching hotter and hotter keys and is cheap, while 85% to 90% means buying memory for progressively colder keys and can cost more than the first 35 points combined. The FAQ covers how to estimate a miss penalty, how to chain the formula across multi-level caches, and what cache penetration, breakdown and avalanche do to a hit ratio before you see them anywhere else.

How to use Cache Hit Ratio Calculator

  1. Ratio: pick the input mode — enter hits and misses straight from your cache's stats (e.g. Redis INFO keyspace_hits/keyspace_misses), or switch to total requests plus a known hit ratio; read hit ratio, miss ratio and the totals.
  2. Speed: enter the cache hit time, the miss penalty (unit switch for ns or ms) and the hit ratio; read AMAT, the speedup versus no cache, and the marginal gain of one more percentage point of hit ratio.
  3. Offload: enter requests per day, hit ratio, backend latency per miss and cost per 10,000 backend requests; read how many requests the backend never sees, the latency-hours and dollars avoided, and the backend load reduction.
  4. Sizing & Summary: enter object size, object count and capacity to get the share of the dataset that fits, the worst-case hit-ratio ceiling and the capacity a target ratio needs; the Summary tab combines an independent copy of the inputs into one plain-language verdict.

Frequently asked questions

What hit ratio is considered good?

It depends entirely on the miss penalty. A CPU L1 cache below 90% would be slow because RAM is 100x slower; a Redis application cache typically runs 80–95%; a CDN in front of static assets should exceed 90%, while long-tail media may sit lower and still pay off. Instead of chasing a universal number, compute AMAT at your current ratio and at +5 points — the Speed tab shows whether the gain is worth the memory it would cost.

How is the AMAT formula derived?

It is a weighted average over the two paths a request can take. With probability h (the hit ratio) you pay the hit time; with probability 1 − h you pay the miss time. So AMAT = hit time × h + miss time × (1 − h). Textbooks often write it as AMAT = hit time + miss rate × miss penalty, where miss penalty means only the extra time beyond the hit — the two forms are identical when miss time = hit time + penalty. This calculator uses the first form, so enter the full time of a miss.

How do I estimate the miss penalty?

Measure it from the caller's side, not from documentation: the p50 latency of the backend call the cache is hiding, network round trip included. Redis to Postgres is typically 10–50 ms; a CDN edge miss to origin is the full origin fetch, often 100–500 ms across regions; L1 to RAM is about 100 ns. If your misses are reads of a slow query, time that query. Using p50 keeps AMAT honest — p95 tells you about tail risk, not the average.

How does cache size relate to hit ratio?

More capacity holds more of the dataset, so the achievable hit ratio rises — but with diminishing returns. Request popularity follows a Zipf-like distribution: the hottest 1% of keys may carry half the traffic, so the first few gigabytes buy huge gains and each later doubling buys less. The Sizing tab shows the worst case (uniform traffic, where the hit-ratio ceiling equals the resident share); real workloads with a hot head beat that ceiling, which is exactly why LRU works with caches much smaller than the data.

How do I compute hit ratio and AMAT for multi-level caches?

Level by level, from the fastest outward. Each level's hit ratio is measured against the requests that reach it, not the original total: if L1 hits 80% and L2 hits 90% of what L1 missed, L2's contribution is 20% × 90% = 18 points, for a combined 98% before RAM. For time, chain AMAT: AMAT_L1 = hit time_L1 + miss rate_L1 × AMAT_L2, and AMAT_L2 = hit time_L2 + miss rate_L2 × RAM time. The same chaining prices CDN edge → regional tier → origin.

What do cache penetration, breakdown and avalanche do to the hit ratio?

All three show up as a hit-ratio drop before anything else alarms. Penetration: requests for keys that do not exist (scraped IDs, typo storms) can never hit, so they hammer the backend — fix with a bloom filter or by caching null results. Breakdown: one hot key expires and thousands of concurrent requests miss at once — fix with a mutex/single-flight recompute or logical expiry. Avalanche: many keys share a TTL and expire together, collapsing the ratio fleet-wide — fix by jittering TTLs. Watch the ratio's slope, not just its value.

Why isn't a higher hit ratio always better?

Because the last points are the most expensive and each carries hidden costs. Caching colder and colder keys costs memory disproportionate to the traffic they serve. Write-heavy data adds write amplification: every update invalidates or rewrites cache entries, and at some write rate the cache spends more effort staying fresh than it saves. Long TTLs raise the ratio but serve staler data; aggressive caching personalizes responses that should never have been shared. The optimum is where the marginal cost of the next point — memory, invalidation traffic, staleness risk — equals the marginal AMAT it buys.

Is my data uploaded anywhere?

No. Every calculation runs locally in your browser with JavaScript. Nothing you type — hit counts, latencies, request volumes, cache sizes — is transmitted, logged or stored.