Additional Reading—the CAP Theorem

Explore the trade-offs made during distributed system design to help study the decision-making behind scaling back-end systems.

The CAP theorem

Let’s take a break from writing code and take a peek into the decision-making and considerations that usually occur before we start writing our code.

Overview

The CAP theorem, also known as Brewer’s theorem, is a concept that states it is impossible for a distributed data store to simultaneously provide more than two out of the three following guarantees:

  • Consistency: Every read receives the most recent write or an error.

  • Availability: Every request receives a response without a guarantee that it contains the most recent version of the information.

  • Partition tolerance: The system continues to operate despite an arbitrary number of messages being dropped, or delayed, by the network between nodes.

In simpler terms, the CAP theorem states that we can only have two of the following three guarantees in a distributed system: consistency, availability, and partition tolerance.

Principles explained

Let’s take a closer look at each of these guarantees and what they mean.

  • Consistency: When a client reads from the distributed data store, it always receives the most recent write—for example, if one client writes the “apple” value to a key and another client reads from that key shortly after, it should always receive the “apple” value.

  • Availability: The distributed data store is always available to handle requests. This is especially important in mission-critical systems where downtime is not an option.

  • Partition tolerance: The distributed data store can continue operating even when there are network failures or delays between nodes. This is important in distributed systems where not all nodes are guaranteed to be connected at all times.

Get hands-on with 1200+ tech skills courses.