System Design Fundamentals
11 items
11 items
Understanding the fundamental trade-offs in distributed data systems
The CAP theorem states that a distributed system can only guarantee two of three properties: Consistency (all nodes see the same data), Availability (every request gets a response), and Partition tolerance (system works despite network failures). Since network partitions are inevitable, the real choice is between CP (consistent but may be unavailable) and AP (available but may be inconsistent). Beyond CAP, understanding consistency models—strong, eventual, causal—helps you choose the right guarantees for each use case.
CAP only forces a choice during network partitions. In normal operation, you can have all three. The question is: when a partition occurs, do you sacrifice consistency (serve potentially stale data) or availability (reject requests)?
Network partitions will happen—switches fail, cables get cut, cloud regions disconnect. A system that doesn't tolerate partitions isn't distributed. So the real choice is CP or AP, not "pick any two."
Between "immediately consistent everywhere" and "eventually consistent someday" lies a spectrum: linearizable, sequential, causal, read-your-writes, eventual. Most applications need something in the middle, not the extremes.
The CAP theorem (Brewer's theorem) states that a distributed data store can only provide two of these three guarantees:
Consistency (C): Every read receives the most recent write or an error. All nodes see the same data at the same time.
Availability (A): Every request receives a non-error response, without guarantee that it contains the most recent write.
Partition Tolerance (P): The system continues to operate despite network partitions (communication failures between nodes).
The key insight: Network partitions are not optional in distributed systems. Networks fail, packets get lost, data centers disconnect. Any real distributed system must be partition tolerant.
Therefore, the real choice is: When a partition occurs, do you choose: - Consistency (CP): Reject requests to maintain data correctness - Availability (AP): Serve requests but possibly with stale data
CA systems (Consistent + Available, not Partition tolerant) can only exist as single-node systems—traditional RDBMS like PostgreSQL or MySQL before replication.