TTL Optimisation Calculator
Work out ttl optimisation instantly with clear inputs, formula shown and shareable results.
About TTL Optimisation Calculator
For a single hot key, one origin fetch happens per TTL regardless of request rate, so the hit ratio is 1 - 1/(rate x TTL). At 40 requests per second a 60-second TTL yields about 99.96 percent hits. Average staleness is half the shorter of the TTL and the data's change interval, which is the number to weigh against the correctness requirement.
Formula
TTL economics
refreshes per second = 1 / TTL; hit ratio = 1 - 1/(rate x TTL); average staleness = min(TTL, change interval) / 2
Worked example
With the default values below, TTL Optimisation Calculator returns Hit ratio at this TTL of 99.96%. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Requests per second for the keyminimum 0.001
- 40
- Cache TTLminimum 0.1 s
- 60 s
- How often the underlying data changesminimum 0.1 s
- 300 s
- Origin cost per requestminimum 0
- 0.00004
Results
- Hit ratio at this TTL
- 99.96%
- Origin refreshes per hour
- 60.0
- Average staleness of served data
- 30.0 s
- Monthly origin cost for this key
- $1.7280
Step by step
- 1Values used
- 2TTL economics
- 3Hit ratio at this TTL= 99.96
- 4Origin refreshes per hour= 60.0
- 5Average staleness of served data= 30.0 s
- 6Monthly origin cost for this key= 1.7280
Assumptions and limits
- The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax 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
Why does a longer TTL barely improve the hit ratio?
Because the hit ratio is already near one. Going from 60 to 600 seconds moves it from 99.96 to 99.996 percent, buying almost nothing while multiplying staleness tenfold.
What is a cache stampede?
When a popular key expires and many requests miss simultaneously. Use a lock or single-flight so only one request refills, or refresh proactively before expiry.
Related Calculators
- Alert Noise Ratio Calculator
- Apdex Score Calculator
- Artifact Retention Calculator
- Automation ROI Calculator
- Autoscaling Threshold Calculator
- Availability From Error Rate Calculator
- Blue Green Cutover Time Calculator
- Bug Escape Rate Calculator
- Build Minutes Cost Calculator
- Build Time Savings From Cache Calculator
You might also need
- Apdex Score CalculatorAlso in DevOps, SRE & Performance
- Artifact Retention CalculatorAlso in DevOps, SRE & Performance
- Automation ROI CalculatorAlso in DevOps, SRE & Performance
- Autoscaling Threshold CalculatorAlso in DevOps, SRE & Performance
- Capacity Headroom CalculatorAlso in DevOps, SRE & Performance
- CI Pipeline Duration CalculatorAlso in DevOps, SRE & Performance
