We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
3 system design questions lean on this idea. Each walks through the full answer.
System Design Masterclass · Caching Strategies
Free preview: the first 2 parts of this 12-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Caching Strategies
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
The previous lesson measured what cache-aside costs: the key computed at every call site, the value shape assumed at every call site, and a failure path that only exists where somebody wrote it. Read-through moves the fetch inside the cache. The application asks for a key, and the cache loads it if it is not there.

The key, the time to live, the single flight and the fetch all move into one loader. So does what happens when that fetch fails, and that is the one this lesson is about.

That is a much stronger property than being fixed. A bug that cannot be expressed does not come back when somebody adds a sixth call site next quarter.

This is the stampede from the lazy loading lesson, removed by construction. It is worth more than it looks, because the stampede is worst on your most popular key immediately after a restart.
Centralising the fetch is a genuine improvement and it is also why the failure behaviour stops being obvious. In cache-aside somebody had to write a try block. In read-through somebody has to know what the library already does.

Nothing about read-through picks one for you. The library has a default and most teams inherit it without ever choosing, which is fine until the day the source is unavailable for three seconds.

a fallback under the normal time to live produced zero errors and 1,307 wrong answers, and the last of them was served 297 seconds after the source had recovered.