🧠 Size a Redis cache for a busy API
Software & CloudThe database is drowning in reads. A cache keeps the hottest data in memory: how big must it be to protect the database and make the API fast, without paying for memory you do not need?
⭐ Level 1: Trainee0 XP · next level at 300
Cache hit ratio37.5%
Average read time✗ 25.4 ms
Queries reaching the database✗ 6,249 /s (max 3,000)
Cache cost (illustrative)₹1,200 / month
The database is overloaded: grow the cache.
📘 How it works
Most reads go to a small set of hot keys, so even a cache smaller than the data catches most of them. Every miss still hits the database, so at high traffic the last few percent of hit ratio decide whether the database survives.
hit ≈ 0.99 × (cache ÷ working set)^0.35 · DB load = req/s × (1 − hit) · avg = hit × 1 ms + miss × 40 msA simplified textbook model for learning. Real designs follow the full codes and standards.