The CAP theorem, also named as Brewer's theorem states that it is impossible for a distributed data store to simultaneously provide more than two out of the following three guarantees:
- Consistency: Every read receives the most recent write or an error
- Availability: Every request receives a non-error response, without the guarantee that it contains the most recent write
- Partition tolerante: The system continues to operate despite an arbitrary number of messages being dropped.
| System Type | Guarantees Provided | Description |
|---|---|---|
| CA System | Consistency + Availability | A single-machine database has no partition issues, so it can guarantee both consistency and availability. |
| CP System | Consistency + Partition Tolerance | When a network partition occurs, the system sacrifices availability (rejecting some requests) to maintain consistency. |
| AP System | Availability + Partition Tolerance | When a network partition occurs, the system continues to provide services, but data may be temporarily inconsistent (eventual consistency). |
In practical system design, since distributed systems must have partition tolerance (P), developers usually have to make trade-offs between consistency (C) and availability (A). This has led to the BASE theory (Basically Available, Soft state, Eventually consistent), which emphasizes eventual consistency rather than strong consistency. So, BASE mitigate CAP by choosing a practical balance of "Be available now, consistent later.”