Skip to content
hostcomplex

CAP Theorem

Maarten Soetens 2 min read

What the CAP Theorem States

The CAP theorem is a principle about distributed databases, which store data on several connected nodes. It states that when a network partition occurs, a system must choose between consistency and availability. A partition is a break in communication between nodes, such as a cable fault that splits a cluster into groups that cannot reach each other.

Eric Brewer proposed the idea in the early 2000s, and it was later proven formally. The three letters stand for:

  • Consistency: every read returns the most recent write, or an error.
  • Availability: every request receives a response, even if the data might be stale.
  • Partition tolerance: the system keeps operating when messages between nodes are lost or delayed.

Why the Choice Is Consistency or Availability

Partitions happen in real networks, so a distributed system has to tolerate them. That leaves a practical choice during a partition. A system can refuse some requests to keep its data consistent, or it can keep answering and risk returning out-of-date values until the nodes reconnect.

The popular phrase “pick two of three” is a simplification. The theorem applies only while a partition exists. When the network is healthy, a well-built system can offer both consistency and availability. Later models extend the idea, including PACELC, which adds the trade-off between latency and consistency when there is no partition.

Eventual Consistency and Real-World Examples

Eventual consistency means replicas may disagree for a short time but converge on the same data once updates have spread. It is common in systems that favour availability, such as a social media post’s like count, where a slightly stale number is acceptable.

A bank balance or a seat reserved on a flight calls for stronger consistency, because two customers should not be sold the same seat. Many real systems mix the two, using strong guarantees for critical operations and weaker ones elsewhere. Comparing how SQL and NoSQL databases make these trade-offs is a useful next step.

Frequently asked questions

Does the CAP theorem apply to a single MySQL database?

Not in the usual sense. CAP concerns distributed systems that span several nodes and must cope with partitions. A single database server does not face the same choice, although its transactions still need guarantees, which are covered by ACID transactions. Replication across servers brings CAP considerations back.

Is CAP the same as ACID?

No. ACID describes the guarantees a database gives within one system for transactions, such as atomicity and isolation. CAP describes the trade-off between consistency and availability when a distributed system is split by a network failure. The two share the word consistency, but it means different things in each.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.