Code Room
System designMedium
Question
Your in-memory cache (fixed 64GB) is showing a low hit rate even though the popular working set easily fits in memory. Investigation shows occasional large scans (a batch job, a crawler) pull in thousands of one-hit-wonder keys that evict the genuinely hot keys under plain LRU — cache pollution. Design an eviction/admission policy that resists scan pollution, keeps the genuinely hot working set resident, and adapts as the popularity distribution shifts over time. Discuss how you'd measure that it's working.
What a strong answer looks like
Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts — data model, bottlenecks, consistency, failure modes — and name the trade-offs you are making.
Learn the concepts
Loading whiteboard…
Run or narrate your approach, then ask the coach.