Skip to content
Theory · Caching at system level · lesson 5 of 7

Cache stampede

The store's home page shows a product of the day, and its card is viewed 5,000 times a second. The cache serves it with ease until, at 12:00, the key's time to live runs out. Up to that second the cache carried almost the whole load on one card — and suddenly it stops. Interviewers like this case: it checks whether you see that a cache protects the database only while it holds a copy.

In this lesson

  • What happens in 100 milliseconds
  • One goes to the database
  • Serve the old one while the new one is built
  • Refresh ahead
  • When many keys expire at once
  • Common mistake
  • Key points