Review cards · 24 cards

Caching

Cache-aside, write policies, eviction, invalidation and hot keys.

Train caching in daily review

Cards

  1. Walk through a read with the cache-aside pattern. easy Flashcard
  2. What do you trade when you choose a cache TTL? easy Flashcard
  3. Why do sites name static files with a content hash, like app.3f9a2c.js? easy Flashcard
  4. A service gets 100,000 reads/s, and its cache hit rate is 95%. How many reads per second reach the database? easy Estimate
  5. Storing "this key does not exist" in the cache, so repeated lookups for a missing item do not all reach the database, is called _____. easy Fill in the blank
  6. A cache hit takes 1 ms. A miss takes 20 ms (cache check plus database read). With a 90% hit rate, what is the average read latency? medium Estimate
  7. Which decision should never be made from a cache alone? medium Multiple choice
  8. When a hot key expires and thousands of requests miss at once and all hit the database, it is a _____. Letting one request rebuild the value while the others wait for it is called _____. medium Fill in the blank
  9. You want CDNs to cache a page for a day but browsers for only a minute. Which header does that? medium Multiple choice
  10. Why can restarting a whole cache cluster take down the database behind it, and how do you avoid that? medium Flashcard
  11. A feed cache stores each user's feed as a list of post ids, and the posts themselves in a separate cache. Why split them? medium Multiple choice
  12. A thumbnail takes 50 ms of worker time to render and is viewed thousands of times. Why store it instead of rendering it again on each CDN miss? medium Flashcard
  13. A ranking model needs features computed from months of logged interactions for each of 500 candidates, within a 300 ms budget. Where should a request read them? medium Multiple choice
  14. When would you choose Redis over Memcached as a cache? medium Flashcard
  15. You add an in-process cache on each app server in front of a shared Redis. What do you gain and what do you pay? medium Flashcard
  16. A job imports 50 million records that are rarely read in the days after. Which cache write policy fits? medium Multiple choice
  17. Which cache write policy can lose acknowledged writes if the cache node crashes? medium Multiple choice
  18. After updating a row in the database, why do most cache-aside systems delete the cache key rather than write the new value into it? hard Multiple choice
  19. To keep a hot key from expiring under load, a reader can refresh it at random shortly before its TTL ends, more likely the closer expiry is. This is _____. hard Fill in the blank
  20. One cache key gets 1 million reads a second, more than a single cache node can serve. What are the usual fixes? hard Flashcard
  21. What is the weakness of plain LFU eviction, and how do real caches handle it? hard Flashcard
  22. Every night a batch job reads each of millions of keys once, and the next morning the cache hit rate has collapsed. Which eviction policy would have resisted that? hard Multiple choice
  23. Each region has its own cache in front of a database that replicates between regions. A write lands in region A. How does region B's cache stop serving the old value, without replicating the cache itself? hard Flashcard
  24. Even with delete-on-write, cache-aside can end up caching a stale value. How, and what bounds the damage? hard Flashcard

More topics