SDE Path

Cache Sizing with the 80/20 Rule

Medium

A social service stores 500 million profiles at 2 KB each. Access follows the Pareto rule: 20% of profiles get 80% of reads. The system serves 100K profile reads/sec. A DB read costs 10 ms, a cache hit 0.1 ms.

Use: 1 day = 86,400 sec ≈ 10^5 sec. Powers of 10: 1 KB = 10^3 B, 1 MB = 10^6 B, 1 GB = 10^9 B, 1 TB = 10^12 B, 1 PB = 10^15 B.

Compute total storage, the cache size for the hot set, the hit ratio it buys, and the resulting average latency.

Back-of-envelope counts: any answer within ±30% of the target is correct, just like a real interview. Suffixes like k, M, B work.