System Design · interactive
CAP: consistency or availability
Networks split. When one replica can't reach the others, it has two choices for a request: refuse it, or answer with what it has, which may be out of date. You have to pick one. Try both.
Replica A
x = 1
up to date
Replica B
x = 1
up to date
Replica C
x = 1
up to date
Network healthy
All three replicas agree: x = 1.
During a partition, prefer
1 Three copies of the data, so one machine can fail without losing it.
A, B and C all hold x = 1
2 3 4
In production
Tools and technologies
Every replicated database makes this choice; most let you tune it per request.
Not tied to one language — use these names when you search docs or design a system.
- Cassandra consistency levelsSoftware
Choose ONE, QUORUM or ALL per read and write.
Official site ↗ - etcdSoftware
Raft-based key-value store that refuses writes without a majority (CP).
Official site ↗ - Amazon DynamoDBService
Eventually consistent reads by default; strongly consistent on request.
Official site ↗ - JepsenSoftware
Tests what databases really do during partitions.
Official site ↗