Chapter 6 checkpoint

Caching and invalidation

Every question from this chapter’s lessons, grouped by the lesson that teaches it. Answer each one right to finish; you can try again whenever you like.

0 of 17 answered right

6.1 Caching tiers and cache placement

0 of 5 answered right
Open the lesson
Question 1
A cache answers in 2 ms and the database in 38 ms. A miss checks the cache and then queries the database. With a 95% hit ratio, what is the average response time per request?

Answers within 1% count, in any unit you choose.

Question 2
A catalog has 10 million products, 20% of which receive most reads. Each cached item is 2 KB, and you allow 25% extra for overhead. How much RAM does the cache need for that working set, in GB?

Answers within 5% count, in any unit you choose.

Question 3
The cache hit ratio falls from 99% to 95%. By what factor does the number of queries reaching the database grow?
×

Answers within 2% count.

Question 4
Match each caching tier to an example the lesson gives.

Question 5
A product service serves 50,000 reads a second. A deploy changes the cache keys, and the hit ratio falls from 99% to 90%. Which component saturates first?

6.2 Cache invalidation and update strategies

0 of 4 answered right
Open the lesson
Question 6
With cache-aside, why should a write delete the cache entry instead of setting it to the new value?

Question 7
Match each cache update strategy to how it works.

Question 8
What do you give up by choosing write-behind instead of write-through?

Question 9
A reader misses the cache, reads V1V_1 from the database and stalls. Meanwhile a writer stores V2V_2 and deletes the key. The reader then puts V1V_1 into the cache. What prevents this “stale set”?

6.3 Stampedes, penetration and avalanches

0 of 4 answered right
Open the lesson
Question 10
Millions of requests for product ids that do not exist, such as /product/-999999, miss the cache and reach the database. What stops them?

Question 11
How does XFetch (probabilistic early expiration) shrink cache stampedes?

Question 12
Exactly one hour after a deploy, database load spikes sharply and then settles. All cache entries were filled at startup with a one-hour TTL. What prevents it next time?

Question 13
A worker takes a Redis lock with SET lock:key token NX PX 5000 before recomputing a hot key. Why should the value be a random token?

6.4 Eviction algorithms and memory management

0 of 4 answered right
Open the lesson
Question 14
A nightly job reads every row of a large table once, through an LRU cache. Next morning the hit ratio is terrible. Why?

Question 15
Match each eviction algorithm to what it evicts.

Question 16
A Redis cache holds keys without TTLs, and a small subset is read far more often than the rest. Which maxmemory-policy does Redis suggest as a good default?

Question 17
A Redis instance uses volatile-lru, and none of its keys has a TTL. When memory fills, what happens?