AI System Design
← Learn
Level 3advanced

CAP & Consistency

Pick two. Actually, pick your poison.

Depth:
1

Mission

A network partition splits your cluster. Do you keep serving (risking stale data) or stop (staying consistent)?
2

Interactive Simulation

Before we explain anything — play. Push it until it breaks, then fix it.

R + W = 2 ≤ 3 — fast, but a read can miss a just-written value. Now cut the network.
Availability
100.0%
Stale reads
4.0%
Guarantee
Eventual
R+W=2 vs N=3
Divergent writes
No
needs reconciliation
Requests
3.0K/s
Latency
7ms
p95 20ms
Error rate
0.0%
CPU
40%
Accepted
3.0K/s
Latency (ms)
Error rate (%)

Quorums (N = 3)

Read quorum R — replicas that must answer a read
Write quorum W — replicas that must ack a write

R + W > N means every read set overlaps every write set — that's what "strong" buys you.

Break it

System Score99
3

What just happened?

During the partition you had to choose: remain Available (serve possibly-stale data) or remain Consistent (reject some requests). You can't have both while partitioned.

4

The concept

CAP: during a network Partition, a distributed system must choose between Consistency (every read sees the latest write) and Availability (every request gets a response). Since partitions happen, real systems pick CP or AP behavior. Eventual consistency (AP) means replicas converge over time.

5

Trade-offs

Nothing is free. Here's what this solution costs you.

Consistency
Simpler reasoning, but lower availability under partitions.
Availability
Always answers, but reads can be stale.
6

Mini quiz

Question 1 of 30 correct

During a network partition, CAP forces a choice between…

7

Interview me

The app becomes your interviewer. One question, in your own words.

8

Boss challenge

Payments ledger under partition

You run a bank's balance store across two regions. The link between them just failed.

Goal: Serve no stale balances and accept no conflicting writes, while still answering 60%+ of requests.

Use the simulator above with no hints. These checks update live as you play.

9

Interview question

“Explain CAP, give an example of a CP and an AP system, and define eventual consistency and quorums.”

Next: Key-Value Store