Caching medium
A malicious bot requests random, non-existent keys (e.g., /user/x8z9q) at a high rate. Since these keys are missing, every request hits the database, causing high load. What is the standard defense?
- A Implement a 'Write-Behind' (Write-Back) caching strategy to buffer incoming requests in a persistent background execution queue.
- B Utilize a Bloom Filter to probabilistically verify element existence, or store 'Not Found' results in the cache with a short TTL.
- C Transition the cache eviction logic to a 'Least Frequently Used' (LFU) policy to ensure that rarely accessed keys are purged immediately.
- D Configure the cache cluster to ignore Time-To-Live (TTL) expiration signals for any key that does not have a corresponding database record.
Answer: B. Utilize a Bloom Filter to probabilistically verify element existence, or store 'Not Found' results in the cache with a short TTL.
**Cache Penetration** occurs when requests for non-existent keys bypass the cache (Cache Miss) and hit the database. Malicious actors can exploit this. A **Bloom Filter** is a memory-efficient probabilistic data structure that can tell you if a key *definitely does not exist*. Using this check before querying the DB blocks the vast majority of invalid requests.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- In the Cache-Aside pattern, what happens when the application requests data that is missing from the cache (a 'Cache Miss')?
- Why use a centralized Distributed Cache (like a Redis Cluster) over local in-memory caches on each web server?
- Setting a short TTL (e.g., 60 seconds) on a cached object helps to:
- What is the primary architectural goal of introducing a cache into a system?
- Most caching systems rely on the principle of 'Temporal Locality', which states:
- Your cache uses an LRU (Least Recently Used) eviction policy. When the cache is full, which item is removed?