CAP Theorem & PACELC
Choose clearly between consistency and availability when network links inevitably split.
In plain words
When the network between servers breaks, a distributed system must choose: refuse some requests to stay correct, or keep answering with possibly stale data. CAP names that trade-off.
Think of it like…
Two bank tellers lose phone contact: either they freeze withdrawals until the phone works (CP) or let customers withdraw from stale balances and reconcile later (AP).
Where you’ve seen it
During a network split, a bank prefers to reject a transfer rather than risk a wrong balance (consistency). A shopping cart prefers to keep working and fix conflicts later (availability).
Words you’ll hear
- Consistency
- Every read sees the latest write.
- Availability
- Every request gets a response, even during failures.
- Partition
- A network break that stops some servers from talking to others.
- PACELC
- Even without a partition, you still trade latency against consistency.
Visual diagram
Theory & deep dive
What CAP actually says (and the common myth)
People often say "pick any 2 of Consistency, Availability, Partition Tolerance." In reality, you cannot opt out of network partitions - fiber cables get cut and switches reboot. So when a partition happens (P), you must choose between Consistency (C) and Availability (A).
And PACELC adds the everyday reality when the network is healthy (Else): you STILL choose between Latency (L) and Consistency (C) - waiting for cross-region replicas slows writes down, while returning immediately risks stale reads.
How it works, step by step
Step 1 of 41. Recognize that partitions (P) are non-optional
Switches drop packets, cross-AZ fibers get cut, and GC pauses look identical to dead links. A distributed store must always tolerate P.
- Partition Cause
- Link cut / GC pause
- CA Systems
- Single-node only
When to use it & trade-offs
What it is
CAP states that during a network partition (P), a distributed data store must choose between linearizable Consistency (C) and 100% Availability (A). PACELC extends this: even without partitions (E), you still trade Latency (L) vs. Consistency (C).
Why it matters: Network partitions always happen in real clusters, so “CA” is impossible for distributed systems - you must decide per feature whether stale data or an error is safer.
When to reach for it
- CP for money transfers, ticket holds, auth token revocation, and leader election
- AP for timeline caches, product descriptions, likes/views, and collaborative drafts (with CRDTs)
- Mixing both in one product: CP for checkout, AP for product catalog browsing
When to avoid or be careful
- Claiming a distributed database is “CA” (single-node DBs aren’t partition-tolerant; distributed ones must handle P)
- Applying one blanket CAP label to an entire app instead of per data domain
CP vs. AP & PACELC Profiles
Strengths: Every successful read sees the latest committed write; no split-brain corruption.
Watch out: Minority nodes reject requests during partitions; synchronous quorum adds write latency.
Strengths: High uptime and low latency even across flaky cross-region links.
Watch out: Clients may observe stale reads or concurrent write conflicts that need resolution.
Strengths: Clarifies that even without outages, quorum/sync writes cost extra network RTT.
Watch out: Must explicitly pick which endpoints (e.g., checkout vs. browsing) pay the latency cost.
Interview signals & numbers to know
When this topic comes up
- network partition
- split brain
- strong consistency vs availability
- multi-region
- inventory
Benchmarks & rules of thumb
- Quorum formula
- W + R > N
- Typical quorum (N=3)
- W=2, R=2
- Same-region quorum RTT
- ~0.5–2 ms
- Cross-region quorum RTT
- ~50–150 ms
Common mistakes & follow-ups
Common interview mistakes
- Saying “we pick CA because our AWS network is reliable” - partitions still happen in every cloud
- Treating CAP as binary across the whole app rather than per subsystem (checkout = CP, catalog = AP)
- Forgetting PACELC: in normal operation, you still trade latency for consistency
Likely interviewer follow-ups
- Why is a “CA” distributed system considered impossible in practice?
- How does PACELC refine CAP for healthy networks?
- In an e-commerce site, which subsystems should be CP and which can be AP?
Knowledge check
Put it into practice
Design full architectures with AI feedback
Apply CAP Theorem & PACELC inside real High-Level Design prompts or review Q&A flashcards.