Code Room
System designMediumsd-g316
Subject CachingLevel Mid–Senior~35 minCommon in Distributed systems interviewsIndustries Technology

Question

A public API gets hammered with requests for resources that don't exist — scrapers and a misbehaving client repeatedly request random/deleted IDs. Each 'not found' lookup still queries the database (cache only stores hits), so the miss traffic saturates the DB. Design negative caching for this system: how you cache the absence of a value, how you bound the memory cost when an attacker enumerates infinite non-existent keys, how you avoid serving '404' for a key that gets created moments later, and the security angle.

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.

Narrate your design
Loading whiteboard…
Run or narrate your approach, then ask the coach.