Beyond CAP: Understanding the PACELC Theorem
The CAP theorem (Consistency, Availability, Partition-tolerance) is a useful abstraction, but it only describes what happens when the network is broken. In the real world, the network is "fine" 99% of the time. PACELC fills the gap.
1. What is PACELC?
PACELC is an extension of CAP. It is read as:
- If there is a Partition (P), choose between Availability (A) and Consistency (C).
- Else (E), choose between Latency (L) and Consistency (C).
2. The Latency-Consistency Trade-off
When you write to a distributed database like DynamoDB or Cassandra during normal operation:
- High Consistency (EC): The system waits for all replicas to acknowledge the write. This is safe but increases Latency.
- Low Latency (EL): The system acknowledges the write after hitting one node and replicates to others in the background. This is fast but risks stale reads (Eventual Consistency).
3. Real-world DB Mapping
- DynamoDB/Cassandra (PA/EL): Prioritize availability during partitions and low latency during normal operation via asynchronous replication.
- MongoDB (PA/EC): Available during partitions, but prioritizes consistency by waiting for primary acknowledgment by default.
Summary
PACELC provides a more realistic framework for architects. If you are building a Stock Matching Engine, you must choose PC/EC. If you are building a Social Media Feed, you choose PA/EL.
Next: Case Study: Designing Stripe’s Ledger System Related: Consistent Hashing: The Core of Distributed Scale
