Work out ttl optimisation instantly with clear inputs, formula shown and shareable results.
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.
TTL economics
refreshes per second = 1 / TTL; hit ratio = 1 - 1/(rate x TTL); average staleness = min(TTL, change interval) / 2
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.
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.