CS FundamentalsVery hardProduct-company placement

A popular product page is cached with a fixed 60-second TTL. Every minute, as the entry expires, thousands of requests miss at once and all query the database, which then times out. Which change addresses this?

  1. A. Lower the TTL to 10 seconds
  2. B. Let only one request recompute a missing key while the others wait or get the stale value (request coalescing), and add jitter to TTLs
  3. C. Write every update to the cache and the database in parallel
  4. D. Disable the cache during peak hours

Correct answer: B. Let only one request recompute a missing key while the others wait or get the stale value (request coalescing), and add jitter to TTLs

This is a cache stampede (thundering herd). Single-flight recomputation, serving stale data while refreshing early, and randomised TTLs stop many clients from hitting the database for the same key at the same moment. A shorter TTL makes it more frequent.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic