The CAP Theorem
Pick two, really one.
When data lives on several machines, the network between them can break. The CAP theorem says what you can promise when it does.

- Data on many machines
- Networks can break
- What can you promise?
C, A and P
C is consistency. Every read sees the latest write. A is availability. Every request gets an answer. P is partition tolerance. The system keeps going even when machines can't reach each other. Networks do fail, so P isn't optional. The real choice is what to give up during a failure, C or A.
| Letter | Promise |
|---|---|
| C: Consistency | every read sees the latest write |
| A: Availability | every request gets an answer |
| P: Partition tolerance | survives a broken network |
CP or AP
So when the network splits, you choose. ACP system refuses some requests, rather than return old data. Banks and stock levels often want this. An AP system answers everything, even if some answers are a bit out of date. Social feeds and like counts are fine with that.
CP: correct or nothing
- May refuse requestsNever stalePayments, stock
AP: always answer
- Always respondsMay be staleFeeds, likes, carts
Summary
CAP says that during a network split, you must choose consistency or availability. Pick per feature, based on what being wrong would cost. Next, the range of consistency between those extremes.
Key takeaways- Partitions happen
- Choose C or A
- Decide per feature