What is the CAP theorem?
EasyConceptCAP, Consistency & Availability
Answer
The CAP theorem states that when a network partition occurs, a distributed data store must choose between consistency (every read sees the latest write) and availability (every request to a non-failed node receives a non-error response). Partitions cannot be ruled out in real networks, so the practical choice is between CP and AP behaviour during a partition.
- CP systems (for example, ZooKeeper or HBase) reject or delay some requests rather than return stale data.
- AP systems (for example, Cassandra at consistency level ONE) keep answering and reconcile divergent replicas later.
- PACELC extends CAP: even without a partition, a system trades latency against consistency.
- The C in CAP means linearizability, which is different from the C in ACID.
More in CAP, Consistency & Availability
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | What is the CAP theorem? | Concept | Easy | Read the answer to What is the CAP theorem? | |||
| 2 | What is the difference between strong consistency and eventual consistency? | Concept | Medium | Read the answer to What is the difference between strong consistency and eventual consistency? | |||
| 3 | How is availability measured, and what do SLAs, SLOs and the 'nines' mean? | Concept | Medium | Read the answer to How is availability measured, and what do SLAs, SLOs and the 'nines' mean? | |||
| 4 | How do quorum reads and writes work, and why does R + W > N matter? | Concept | Hard | Read the answer to How do quorum reads and writes work, and why does R + W > N matter? |