Toolvito

Works on this device

Cache Hit Ratio Calculator

Find the hit ratio of a cache from its hits and misses, see what a hit ratio does to the requests that reach the system behind the cache and to the mean response time, and work out the hit ratio needed for a target. You type every figure.

Enter your values

The share of requests answered from the cache, from the hits and the misses (or all requests).

Your values

Requests answered from the cache.

Requests the cache had to pass on to the system behind it.

For a byte hit ratio, as your cache or CDN reports it.

Your values are worked out in this browser. They are not sent to a server.

Your result will show here

Fill in the values, then choose Calculate.

How to use this calculator

  1. Choose what you want to work out. Hit ratio from counts is the first choice.
  2. Type the hits and the misses (or the hits and all requests) from your cache or CDN report. Add the data sent for a byte hit ratio.
  3. To see the effect, type the requests, the hit ratio, and the mean time of a hit and of a miss.
  4. Choose Calculate.

The formulas

  • Hit ratio = hits ÷ (hits + misses) × 100. Miss ratio = 100% − hit ratio.
  • Byte hit ratio = data sent from the cache ÷ all data sent × 100.
  • Requests behind the cache = requests × (1 − hit ratio).
  • Mean response time = hit ratio × time of a hit + (1 − hit ratio) × time of a miss. This is the same rule as the average memory access time of a CPU cache.
  • Hit ratio needed = 1 − most requests behind ÷ requests, or (time of a miss − time wanted) ÷ (time of a miss − time of a hit).

Worked examples

Counts: 9,200 hits and 800 misses give a hit ratio of 9,200 ÷ 10,000 = 92%.

Effect: 2,000 requests each second at a 92% hit ratio send 2,000 × 0.08 = 160 requests each second to the system behind. With 2 ms for a hit and 80 ms for a miss, the mean response time is 0.92 × 2 + 0.08 × 80 = 8.24 ms, about 9.7 times faster than with no cache.

Needed: for at most 100 requests each second behind the cache out of 2,000, the hit ratio must be at least 1 − 100 ÷ 2,000 = 95%. For a mean of 10 ms with 2 ms hits and 80 ms misses it must be (80 − 10) ÷ (80 − 2) ≈ 89.74%.

Other tools for the same subject

Limits you should know

  • Counts must come from the same cache and the same time. Reports count stale answers and requests that skip the cache in their own ways.
  • Times are means. A cache that has just started or been emptied has a low hit ratio until it fills.
  • The tool reads no cache and no report. It does the arithmetic of the figures you type.

Related tools