Cache Size Calculator
Size a cache from the working set and the hit rate it should achieve.
About Cache Size Calculator
Hit rate rises with cache size but with diminishing returns, because popular items are cached first. Caching the top tenth of items commonly delivers most of the achievable hit rate. Sizing a cache for the full working set is usually wasteful; the right size is where the hit rate curve flattens.
Formula
Cache Size
Cache size = working set × target hit rate × item size with metadata overhead
- working set
- Distinct items actually accessed in the relevant window
- metadata overhead
- Keys, expiry and eviction bookkeeping per entry
Worked example
With the default values below, Cache Size Calculator returns Cache Size Required of 3.3796. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Unique items in the working setminimum 0
- 2,000,000
- Average item sizeminimum 0 bytes
- 1,800 bytes
- Target hit rateaccepts 0–100 %
- 90 %
- Per-item metadata overheadaccepts 0–100 %
- 12 %
- Memory availableminimum 0.001 GB
- 8 GB
Results
- Cache Size Required
- 3.3796 GB
- Items the Cache Must Hold
- 1,800,000
- Bytes per Cached Item
- 2,016.0 bytes
- Share of Available Memory Used
- 42.245%
- Hit Rate Achievable in Available Memory
- 100.00%
Step by step
- 1Values used
- 2Cache Size
- 3Cache Size Required= 3.3796 GB
- 4Items the Cache Must Hold= 1,800,000
- 5Bytes per Cached Item= 2,016.0 bytes
- 6Share of Available Memory Used= 42.245
- 7Hit Rate Achievable in Available Memory= 100.00
Assumptions and limits
- The result is derived only from the 5 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to 4 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
How is Cache Size calculated?
Cache size = working set × target hit rate × item size with metadata overhead Hit rate rises with cache size but with diminishing returns, because popular items are cached first. Caching the top tenth of items commonly delivers most of the achievable hit rate.
Why does Cache Size matter?
Sizing a cache for the full working set is usually wasteful; the right size is where the hit rate curve flattens.
What values do I need to enter?
This calculator takes 5 inputs: Unique items in the working set, Average item size, Target hit rate, Per-item metadata overhead, Memory available. The pre-filled defaults are a realistic starting point — replace them with figures from your own environment for a result you can act on.
