We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
2 system design questions lean on this idea. Each walks through the full answer.
System Design Masterclass · Consistency Models
Free preview: the first 2 parts of this 8-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 Consistency Models
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”
You post a comment. The page reloads. Your comment is missing. 30 seconds later it appears. Your write went to the primary, but your read hit a replica that had not received the yet.
Read-your-writes guarantees that after you write, your subsequent reads reflect that write. Other users might still see stale data, but YOU see your updates immediately.
This is the consistency model users expect by default. Violating it causes the most user complaints.
Route reads to primary after writes, for a short window after a write (say 5 seconds), read from the primary. After that, read from replicas. Simple but increases primary load.
Read from the write replica, use sticky sessions to pin the user to the replica that received their write.
Client-side optimistic reads, update the client immediately on write, and let the server catch up. This is what most modern SPAs do.
| Approach | Complexity | Failure Mode | |
|---|---|---|---|
| Route to primary | Higher | Low | Primary overload |
| Sticky sessions | Low | Low | Breaks on failover |
| Client-side optimistic | Lowest | Moderate | UI flicker on conflict |