CAP theorem
In short: The CAP theorem states: a distributed system cannot guarantee both consistency and availability during a network failure.
In more detail: Of the three properties consistency (everyone sees the same data), availability (every request gets an answer) and partition tolerance (the system runs despite a network split), you can only have two in the failure case. Since network failures occur, you must choose between C and A.
In Depth
- CP systems: prefer consistency, refuse answers if in doubt (for example many consensus stores).
- AP systems: prefer availability, may deliver stale data (for example some wide-column databases, DNS).
- Eventual consistency: data converges over time.
- In practice: You decide per data type. Account balances need consistency, a “like” counter does not.
See also: Database transactions and ACID, Scaling