Architecture 2025-08-02

CAP Theorem Explained: Understanding Distributed Database Trade-offs

Understand the CAP theorem and PACELC theorem with clear examples. Learn the distributed system trade-offs between consistency, availability, and partition tolerance.

Read in: ja
CAP Theorem Explained: Understanding Distributed Database Trade-offs

This post discusses the important theories of the CAP theorem and PACELC theorem in distributed systems.

What is the CAP Theorem

The CAP theorem states that in a distributed system, only two out of the following three properties can be achieved simultaneously:

Since partition (P) is unavoidable in distributed systems, you are essentially forced to choose between C or A.

Misleading Aspects of the CAP Theorem

The formula of "two out of three" in the CAP theorem is misleading for the following reasons:

  1. Partitions rarely occur: In a state without partitions, neither C nor A is lost.
  2. Granular choices: Different choices can be made for different operations or data within the same system.
  3. Degree of properties: The three attributes are not binary; they exist on a spectrum.

Example:

System Classification Explanation
Zookeeper CP Maintains consistency at the cost of availability
Cassandra AP Sacrifices consistency for high availability

What is the PACELC Theorem

The CAP theorem has an important gap: it does not address the trade-offs when no partition occurs.

The PACELC theorem was introduced to complement this issue. According to the PACELC theorem, when a partition (P) occurs, the system must trade off between availability (A) and consistency (C). When there is no partition (E), the system must trade off between latency (L) and consistency (C).

In other words, distributed systems face different trade-offs in the following two situations:

This indicates that even during normal times when no partition occurs, maintaining strong consistency incurs latency due to communication, and if low latency is prioritized, consistency must be relaxed.

Components of the PACELC Theorem:

flowchart TD A[Operational State of Distributed System] --> B{Is there a network partition?<br/>} B -->|Yes P| C{Which to choose?} B -->|No E| D{Which to choose?} C -->|Prioritize Availability| E[PA] C -->|Prioritize Consistency| F[PC] D -->|Prioritize Latency| G[EL] D -->|Prioritize Consistency| H[EC] style A fill:#e1f5fe style B fill:#fff3e0 style C fill:#fce4ec style D fill:#fce4ec style E fill:#e8f5e8 style F fill:#e8f5e8 style G fill:#e8f5e8 style H fill:#e8f5e8

Characteristics of Each Classification:

This theorem allows designers of distributed systems to clearly organize design decisions for both normal and abnormal situations.

Conclusion

In designing distributed systems, it is important to consider both the CAP theorem and PACELC theorem. This enables a clear understanding of the trade-offs regarding system availability, consistency, and latency, allowing for appropriate design choices.

References

Tags: CAP PACELC Distributed Systems
Share: 𝕏 Post Facebook Hatena
✏️ View source / Discuss on GitHub
☕ Support

If you enjoy this blog, consider supporting it. Every bit helps keep it running!


Related Articles