Thundering Herd Problem 00:00:01 Ten requests arrive at the same missing product A popular product page expires just before a promotion. Ten application requests arrive while the first database lookup is still running. Count how many origin reads the uncomplicated cache-aside path can start. The TTL of product 123 ends. They come within a few milliseconds. Each one looks into the cache and finds nothing. The queries compete, so each takes longer. Some callers time out. All ten store the same value. Nine of the ten queries were wasted. Equal queries do not become one query merely because their answers will match. A slow origin lengthens the interval during which additional misses can join the burst. 00:00:46 Elect one temporary loader Give the first miss a bounded loading claim. The others wait or follow a chosen fallback. Inspect the cache again after acquiring a claim because another loader may already have filled it. Same start. Same traffic. Nobody has the value yet. Only request 1 asks the database. The waiters wake at slightly different times and read the fresh value. One query served ten readers. Release only the claim actually owned by the completing worker. If a stalled loader outlives its lease, prevent its late result from overwriting a newer version. 00:01:24 Let callers share a running promise On one application instance the first requester starts a load and stores its in-flight result under the product key. Later requesters can join that work without repeatedly polling an external lock. Request 1 finds no running call for this key and starts one. Requests 2 to 10 find the running call and wait for its result. The result returns once and is shared. Local coalescing gives at most one active call per key in that local domain. Ten independent application instances may still start ten loads, so budget capacity accordingly. 00:02:01 Serve yesterday's answer while one worker refreshes Give the product description a soft freshness deadline and a later hard deadline. Between them, an allowed stale answer can leave immediately while a refresh runs. Under 300 seconds: just return it. At 300 seconds the value is stale. Readers still get it, and one refresh starts. One second later the new value is stored. If every refresh failed until 600 seconds, the value is gone and readers must wait for a rebuild. The two deadlines bound a deliberate product decision. Never silently apply that stale-answer policy to an exclusive stock claim or access decision that requires current authority. 00:02:43 The first loader stops responding The refresh owner pauses while everyone else waits. A timeout lets another worker make progress, but the first one can resume afterwards. Follow both prospective writes to the cache. Request 1 needs 12 seconds, the lock lasts 10. Request 2 takes it. Request 1 finishes and deletes the lock, which is not its own. Request 3 gets in. With a token, the delete of request 1 does nothing. One duplicate query, no more. Bound the wait, protect the completion with appropriate ownership or version evidence, and measure actual database calls per expiry. The promotion should generate customer reads rather than a stampede of recomputations.