DISTRIBUTED SYSTEMS & ARCHITECTURE · SUBTOPIC
CP vs. AP Under Network Partitions
Decide when a service should return an error rather than stale data.
IntermediatePart of CAP Theorem & PACELC
Subtopics in CAP Theorem & PACELC (2)
In plain words
If two bank tellers lose phone contact with each other, a CP bank stops withdrawals until the line comes back so nobody spends the same $100 twice. An AP coffee punch-card shop keeps stamping cards and totals them up later.
Think of it like…
ATM refusing cash when offline (CP) vs. airplane tablet taking offline snack orders and syncing after landing (AP).
Loading interactive diagram
Loading interactive exercise
Theory & how it works
Mixing CP and AP inside one product
An e-commerce app isn’t purely CP or AP: product catalog & reviews are AP (keep showing pages even if stale by 5s), while checkout & inventory deduction are CP (never sell the last concert ticket twice).
Key points & practical guide
Summary checklist
- Partitions (P) are inevitable in distributed systems
- CP sacrifices availability on the minority partition
- Split a single app into CP and AP subsystems by criticality
When to use it
- CP for balances, seats, unique usernames, locks
- AP for feeds, caches, likes, analytics
Watch out for
- Claiming a distributed database is "CA" across regions - CA only exists on a single non-partitioned machine
Quick check
Loading quiz