Theoretical Foundations & Practical Trade-offs:
1. CAP Theorem:
- In a distributed data store, when a Network Partition (P) occurs, the system must choose between:
- Consistency (C): Every read receives the most recent write or an error.
- Availability (A): Every non-failing node returns a response, but it may contain stale data.
- Note: Network partitions are unavoidable in real networks, so distributed systems are practically categorized as CP (e.g., etcd, HBase) or AP (e.g., Cassandra, DynamoDB).
2. PACELC Theorem (Extended CAP):
- Addresses a major limitation of CAP: CAP only describes system behavior during a rare network partition.
- Formula: If there is a Partition (P), how does the system trade off Availability (A) and Consistency (C)? Else (E), when the system is running normally, how does it trade off Latency (L) and Consistency (C)?
- Examples:
- Cassandra is PA/EL: Prioritizes Availability during partitions, and Latency during normal operations (eventual consistency).
- MongoDB / HBase is PC/EC: Prioritizes Consistency during partitions, and Consistency over latency during normal operations.