Trade consistency for availability
Apply CAP, consistency models, and quorums to replicated data.
- State what the CAP theorem does and does not say.
- Match product features to consistency models.
- Use R + W > N to reason about quorum reads and writes.
Once data is replicated across machines, the network between them can fail. The CAP theorem says that during a network partition, a system must choose between consistency (every read sees the latest write) and availability (every request gets a non-error response). Partitions are not optional in real networks, so the real choice is what to give up when one happens. PACELC extends this: else, when there is no partition, you still trade latency against consistency.
Consistency models and quorums
- Strong (linearizable): reads always reflect the latest completed write. Needed for balances, inventory, and locks.
- Read-your-writes / monotonic reads: weaker per-user guarantees that feel right to a single user.
- Eventual: if writes stop, replicas converge. Fine for like counts, view counters, and feeds.
Leaderless (Dynamo-style) stores write each key to N replicas. A write succeeds after W acknowledge; a read queries R replicas and takes the newest version. If R + W > N, every read set overlaps every write set, so reads see the latest write.
Checking two settings: with N=3, W=2, R=2, 2 + 2 > 3, so overlap is guaranteed. With N=3, W=1, R=1, 1 + 1 isn’t greater than 3, so stale reads are possible.
Quorum settings are tunable: W = N, R = 1 makes reads fast but writes fragile; W = 1, R = N does the opposite. When replicas diverge, the system must reconcile. Last-write-wins is simple but silently drops concurrent updates; version vectors detect conflicts so the application can merge them; CRDTs are data types that merge automatically.
Practice: tune a quorum
Try it
Up to 15 XPFind settings that overlap
This shows the worst case for N=3: a write reaches only the first W replicas, and a read asks only the last R.
- Which settings guarantee that a read finds the new value?
- Compare W=3, R=1 with W=1, R=3. Click a replica to take it down. Which operation stops working in each?
Each tile is a replica: “new” holds the latest write, and “read” is where a read asks. Click a tile to take that replica down.
Try it
Up to 15 XPHow consistent does this need to be?
One system can make different choices for different features, and saying so is a strong interview move.
“Spending an account balance.”
“Selling the last ticket.”
“A user reloading the bio they just edited.”
“A like counter.”
“Friend suggestions.”
Key takeaways
During a partition you choose consistency or availability; without one you trade latency and consistency.
Match consistency to the feature - strong for money, eventual for counters.
R + W > N makes quorum reads see the latest write.
Lesson quiz
6 questions · pass with 5 correct · up to 50 XP
Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.
Questions about this lesson
Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.
Loading posts…