Caching medium
Comparing Lazy Loading (Cache-Aside) vs Eager Loading (Push/Write-Through), what is a disadvantage of Lazy Loading?
- A It is significantly more complex to implement compared to Eager Loading patterns.
- B Every 'Miss' results in a predictable latency penalty due to the sequential database read and subsequent cache write operations.
- C It tends to fill the cache with vast amounts of unused data that will never be requested again by any active user sessions.
- D It requires the application to implement complex dual-write logic to ensure that the database and cache remain perfectly synchronized.
Answer: B. Every 'Miss' results in a predictable latency penalty due to the sequential database read and subsequent cache write operations.
**Lazy Loading** (Cache-Aside) only populates the cache after a miss. This means the first user to request an item always experiences higher latency (RTT to DB + RTT to Cache). **Eager Loading** (Write-Through or Warming) pre-populates the cache, ensuring the data is ready *before* the read occurs, providing consistent P99 latency at the cost of potentially caching unused data.
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?