The interview question

Add caching to a read-heavy product catalog without letting stale prices cause incorrect orders.

Choose a consistency contract, prevent stampedes, and plan for the moment the cache disappears.

01. Separate cached views from authoritative decisions

A product page can tolerate a short delay in description updates, while checkout must validate the current price and availability. State those contracts separately. Begin with cache-aside reads: look up the cache, fetch from the database on a miss, and populate a bounded-lifetime entry.

Use keys that include every input affecting the response, such as product ID, locale, and schema version. Personalized or permission-dependent content needs an appropriate scope; sharing a key across users can return the wrong representation.

02. Work through an invalidation race

Read request
Cache lookup
Source on miss

A reader misses the cache and starts reading old version 7. A writer commits version 8 and invalidates the key. The slow reader then fills the cache with version 7. Deleting after a write is therefore not a complete consistency protocol.

Depending on the contract, use bounded staleness with TTLs, version-aware cache writes, or a read path that validates authoritative versions. A version check must be coordinated enough to prevent a stale writer from winning; merely attaching a version field without checking it does nothing.

03. Estimate load and protect misses

At 100,000 reads per second with a 95% hit rate, the illustrative database load is 5,000 reads per second. If the cache fails, that becomes 100,000, a twenty-fold increase. A database sized only for normal misses may collapse.

Coalesce concurrent misses for the same key, jitter expirations, prewarm important keys, and bound refill concurrency. Serve stale content only where the product contract permits it. A single popular item can overload one cache shard even when overall storage is balanced.

04. Choose eviction and failure behavior

Memory pressure requires an eviction policy and maximum object sizes. Keep cache entries disposable and measure hit rate by request, bytes, and expensive downstream work. A high hit rate on cheap objects can disguise misses on the costly ones.

Follow-up: invalidation messages are lost during a client disconnect. Clear or revalidate local state according to the tracking protocol instead of assuming silence means freshness. Test cache-loss behavior under load. For checkout, bypassing an uncertain cache and reading authoritative state is preferable to inventing a price.

Practice the follow-up

Self-review

Draw the stale-refill race and explain which guarantee your chosen mitigation actually provides.

Connect this to inventory reservations.

Sources & further reading

Redis: client-side caching. The interview scenario, calculations, and proposed design choices are illustrative.

Continue your preparation

Choose a connected learning path or browse more System design questions. Read our editorial method and attribution policy.