Review cards · 21 cards
Caching
Cache-aside, write policies, eviction, invalidation and hot keys.
Cards
- Walk through a read with the cache-aside pattern.
- What do you trade when you choose a cache TTL?
- Why do sites name static files with a content hash, like app.3f9a2c.js?
- A service gets 100,000 reads/s, and its cache hit rate is 95%. How many reads per second reach the database?
- Storing "this key does not exist" in the cache, so repeated lookups for a missing item do not all reach the database, is called _____.
- 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?
- Which decision should never be made from a cache alone?
- 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 _____.
- You want CDNs to cache a page for a day but browsers for only a minute. Which header does that?
- Why can restarting a whole cache cluster take down the database behind it, and how do you avoid that?
- 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?
- When would you choose Redis over Memcached as a cache?
- 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?
- A job imports 50 million records that are rarely read in the days after. Which cache write policy fits?
- Which cache write policy can lose acknowledged writes if the cache node crashes?
- 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?
- 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 _____.
- One cache key gets 1 million reads a second, more than a single cache node can serve. What are the usual fixes?
- What is the weakness of plain LFU eviction, and how do real caches handle it?
- 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?
- Even with delete-on-write, cache-aside can end up caching a stale value. How, and what bounds the damage?
More topics
- Estimation 21 cards
- Networking 16 cards
- API design 17 cards
- Databases 22 cards
- Replication 15 cards
- Sharding 18 cards
- Consistency 19 cards
- Queues 18 cards
- Streaming 18 cards
- Availability 14 cards
- Resilience 16 cards
- Storage 14 cards
- Realtime 15 cards
- Data structures 16 cards
- Security 17 cards
- Observability 18 cards
- Coordination 16 cards