open atlas
↑ Back to track
System Design Foundations SD · 05 · 05

Caching at scale: multiple-choice review

Multiple-choice synthesis across the caching unit: read/write strategies and their consistency, eviction and TTL, hit-ratio arithmetic, sharding with consistent hashing, the stampede, and the source-of-truth anti-pattern.

SD Senior ◷ 13 min
Level
FoundationsJuniorMiddleSenior

Six questions that cut across the whole unit. Each is a decision you make when you add a cache, review a caching design, or debug one in production — not a definition to recite, but the consistency tradeoff, the hit-ratio arithmetic, and the failure modes that only appear at scale.

Confirm you can pick a read/write strategy by its consistency promise, choose an eviction policy and TTL, turn a hit-ratio change into DB load, shard a cache without nuking it, recognize and fix a stampede, and reject the cache-as-source-of-truth anti-pattern.

Quiz

You need the cache to never be stale relative to the database on writes, and write latency is not a concern. Which write strategy fits, and what is its cost?

Quiz

A cache at its memory limit keeps evicting the homepage (read constantly, inserted at boot) while retaining a once-a-day report. Which eviction policy is configured, and what should it be?

Quiz

A cache fronting 100,000 reads/sec drops from a 99% to a 90% hit ratio after a deploy. By what factor does the read load on the database increase?

Quiz

You shard a cache and want adding or removing a node to disturb as little of the cache as possible. Which scheme, and why not the obvious one?

Quiz

A single hot key with a 60s TTL serves 50,000 RPS; every 60s the database is hit by a burst of thousands of identical queries. What is this, and the most direct fix?

Quiz

A design writes orders only to Redis, acknowledges the client, and flushes to Postgres asynchronously, reading Redis as the authoritative value. What's the core objection?

Recall before you leave
  1. 01
    Why does a 99%→90% hit-ratio drop melt the database?
  2. 02
    Why shard a cache with consistent hashing instead of modulo, and how do you stop a hot-key stampede?
Recap

The through-line is that caching is a set of deliberate tradeoffs, not a switch you flip. A write strategy fixes a consistency promise: write-through is never-stale-on-write (two trips, churn), write-back is fastest but lossy and inconsistent during the flush, write-around skips the cache (first-read miss) — and the read-path cache-aside permits stale reads until a TTL/invalidation. Eviction must be access-aware (LRU/LFU, not FIFO, never noeviction for a cache), and TTL bounds staleness but must be jittered. The number that matters is the hit ratio, because the DB feels the miss rate: 99%→90% hits is a 10× DB load spike. Scaling out demands consistent hashing (only ~1/N keys move on rescale, vs modulo’s mass remap), survives node loss via replication (async, so slightly stale), and must defend the stampede with single-flight. And the deepest rule is that the cache is a disposable copy of an authoritative durable store — never the source of truth. Get these six decisions right and the cache makes reads fast without making the system fragile.

Something unclear?

Ask a question about this lesson. Questions are anonymous and go straight to the author to make the lesson better.

shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.