Skip to main content
Create your own
Lesson illustration

PACELC Theorem: Beyond CAP

Welcome back! In our previous lesson, we established that the CAP theorem forces a choice between consistency and availability during a network partition. However, network partitions are rare events. Most of the time, our distributed systems operate under normal conditions. This raises a crucial question that CAP doesn't answer: what trade-offs are we making every single day?

This lesson will address that gap by introducing the PACELC theorem. Our goal is to explain how this theorem extends CAP by incorporating the critical, everyday trade-off between latency and consistency. Mastering PACELC provides a more complete framework for analyzing distributed data stores, a skill that is essential for designing scalable systems and for demonstrating senior-level expertise in technical interviews.

1. From CAP's Silence to PACELC's Clarity

The CAP theorem is a powerful tool, but its focus is exclusively on failure modes. As we discussed, the choice between Consistency and Availability is only forced when a partition occurs. But what about the 99.9% of the time when the network is healthy? Every write operation to a replicated database presents a choice: do we wait for the data to be copied to all replicas for maximum consistency, or do we respond immediately for minimum latency?

This is the trade-off between Latency (L) and Consistency (C). The following video provides an excellent critique of the CAP theorem's limitations and explains why this L-vs-C trade-off is so fundamental.

Are you Using CAP Theorem Wrong?

This video from the LearnThatStack channel, "Are you Using CAP Theorem Wrong?", perfectly bridges the gap between CAP and PACELC. It explains why CAP is incomplete and how latency is the missing variable.

Watch the video from the beginning until the PACELC decision. Pay close attention to two key ideas: How the video reframes a network "partition" as the result of a timeout—a decision driven by latency. The introduction of the PACELC framework and the clear example from DynamoDB, where higher consistency literally costs more.

The video makes a crucial point: a partition isn't some abstract event; it's what you declare when a component has become unresponsive for too long. That "too long" is a latency decision. This inherent link between latency and partitions is what motivated computer scientist Daniel Abadi to propose the PACELC theorem.

2. Understanding the PACELC Framework

The PACELC theorem is best understood by breaking down its acronym. It states that for a distributed system:

  • If there is a Partition, the system must choose between Availability and Consistency.
  • Else (meaning, during normal operation), the system must choose between Latency and Consistency.

This creates two distinct decision-making scenarios, as illustrated in the diagram below.

This decision tree visualizes the PACELC theorem. The first question is whether the system is partitioned. If yes, you follow the CAP theorem's logic (left branch). If no, you face a different trade-off between latency and consistency (right branch).

This framework gives us a more descriptive way to classify distributed systems. Let's dig into the details with an excellent article from DesignGurus.

System Design Interview Basics: CAP vs. PACELC

This article clearly explains the PACELC theorem and, most importantly, connects it directly to the real-world databases you'll encounter.

First, read the section from the introduction to PACELC. This will formally define the theorem and the four resulting system classifications.

As the article outlines, we can now categorize systems into four main types:

  • PA/EL: Prefers Availability during partitions and Latency during normal operation. These systems are designed to be as responsive as possible, even at the cost of temporary inconsistencies.
  • PC/EC: Prefers Consistency during partitions and Consistency during normal operation. These systems prioritize data correctness above all else, accepting higher latency and potential downtime as the price.
  • PA/EC: Prefers Availability during partitions but Consistency during normal times. This is a common hybrid approach.
  • PC/EL: Prefers Consistency during partitions but Latency otherwise. This combination is rarer in practice.

The real power of this framework comes from applying it to the databases you already know. Your experience with MongoDB, MySQL, and PostgreSQL provides a strong foundation for understanding these trade-offs in concrete terms.

System Design Interview Basics: CAP vs. PACELC

Now, let's connect this theory to practice. Continue reading the same article.

Focus on the section "Mapping real databases". Pay close attention to how it classifies databases like Cassandra, Bigtable, and especially MongoDB, which you have experience with.

Let's summarize how your existing knowledge fits this model:

  • MongoDB (PA/EC): In its default configuration, MongoDB prioritizes consistency during normal operation (EC), as all writes go to a single primary node. However, if a partition isolates that primary, the cluster will elect a new primary from the remaining nodes to stay available (PA), even if it means losing some recent writes from the old primary. This is a classic PA/EC trade-off.
  • PostgreSQL/MySQL (often PC/EC-leaning): In a typical setup with a single primary for writes, you are prioritizing consistency. If you configure synchronous replication, where the primary waits for a replica to confirm a write before responding, you are explicitly choosing Consistency over Latency (EC). During a partition where the primary is unreachable, the system often becomes unavailable for writes until the partition heals or a manual failover occurs, making it lean towards Partition-Consistency (PC).
  • Cassandra/DynamoDB (PA/EL): These databases are designed for massive scale and high availability. They typically choose Availability over Consistency during partitions and Latency over Consistency in normal operation. They achieve low latency by acknowledging writes quickly without waiting for full replication, accepting that reads might be briefly stale.

Notice that modern databases often provide "knobs" (like MongoDB's write concerns or Cassandra's consistency levels) that allow you to slide along the latency/consistency spectrum based on the needs of a specific query. Acknowledging this tunability is a key mark of a senior engineer.

3. Using PACELC in System Design Interviews

In a system design interview, simply reciting the theorem is not enough. The goal is to use it as a thinking framework to justify your architectural choices based on business needs.

This infographic provides a comprehensive overview, connecting CAP, PACELC, and replication strategies. The PACELC section clearly outlines the choice during normal operation versus a partition, and classifies common databases.

Let's see how to apply this framework to a practical problem.

System Design Interview Basics: CAP vs. PACELC

This final reading from the DesignGurus article provides a script for using PACELC in an interview.

Read the sections Linking to Real Decisions, Common Misconceptions, and How to Use in an Interview.

Here's how to structure your answer for a design question, like "Design a checkout service for an e-commerce site":

  1. Identify the Situation (Partition vs. Normal): Start by analyzing the different operations. Placing an order involves writing to an inventory database.
  2. Analyze the PAC Trade-off: "When a network partition happens between the checkout service and the inventory database, what should we do? If we choose Availability (PA), we might accept an order for an out-of-stock item. If we choose Consistency (PC), we might reject a valid order, losing a sale. For inventory, overselling is generally worse, so we must prioritize consistency. We'll design a PC system."
  3. Analyze the ELC Trade-off: "During normal operation, when a user adds an item to their cart, how quickly must the inventory count be updated across all replicas? To guarantee that no other user can simultaneously buy the last item, we need strong consistency. We will accept slightly higher latency on the 'add to cart' write to ensure the inventory is locked and updated correctly. We choose Consistency over Latency (EC)."
  4. State the Conclusion and Choose Technology: "Based on this analysis, we need a PC/EC system for our inventory database. This points towards a transactional, relational database like PostgreSQL in a highly consistent configuration, or a distributed system designed for strong consistency like Google Spanner or a system using Zookeeper for coordination."

This structured reasoning demonstrates that you're not just recalling acronyms but are making deliberate, business-driven engineering decisions.

Conclusion

In this lesson, we moved beyond the partition-only focus of the CAP theorem to embrace the more comprehensive PACELC framework. You now have a more complete mental model for analyzing the fundamental trade-offs in distributed data systems.

Key Takeaways:

  • The CAP theorem is about the trade-off between Availability and Consistency when a Partition occurs.
  • The PACELC theorem extends CAP by adding the trade-off a system must make during normal operation (Else): between Latency and Consistency.
  • This gives us a richer vocabulary (PA/EL, PC/EC, etc.) to describe and compare distributed databases like MongoDB, PostgreSQL, and Cassandra.
  • In a system design interview, use PACELC to reason from business requirements to technical choices, demonstrating your ability to handle complex trade-offs.

We've now established that there's a trade-off between latency and consistency. In our next lesson, we will explore how this trade-off is implemented in practice. We'll dive into database replication, comparing asynchronous and synchronous strategies and seeing how they are the direct mechanisms for realizing the choices described by PACELC.

Can't find a good explanation? Sign up and we'll make it for you

Sign up