Tech●●●●●Difficulty 5 of 5

Why can't a system spread across the world be both always consistent and always available?

When the network between two copies of your data breaks, a system must choose: answer with possibly stale data, or refuse to answer.

▶ Start the story

Because networks break, and when the link between two copies of your data is cut, the copies cannot compare notes. The CAP theorem, also named Brewer's theorem after Eric Brewer, says a can provide at most two of three guarantees: consistency, availability and tolerance. Consistency means every read receives the most recent write, or an error. Availability means every request to a working gets a response, without a guarantee it holds the latest data. Partition tolerance means the system keeps operating even when the network drops or delays messages between nodes.

No distributed system is safe from network failures, so partitions generally have to be tolerated, which leaves two options. When a happens, a system can cancel the operation, lowering availability but ensuring consistency, or proceed, providing availability but risking inconsistency. Say you save a change on one side of a cut network and someone reads it on the other. The system can only return an error or return the old value.

An example: one broken link, two bad options
  1. Step 1: Two copies of the data

    In two places, kept in sync by messages

  2. Step 2: The network between them fails

    A : messages are dropped or delayed

  3. Step 3: A write reaches only one copy

    The other copy is now out of date

  4. Step 4: The system must choose

    Return an error, or answer with the old value

Notice the limit of the claim. In the absence of a , both availability and consistency can be satisfied. Brewer himself clarified in 2012 that "two out of three" can be misleading: designers only need to sacrifice one of them in the presence of partitions, and partition management and recovery techniques exist.

The idea has a founder with a story. Brewer says the theorem first appeared in autumn 1998, and he presented it as a at a major conference in 2000. In 1996 he had co-founded Inktomi and became a paper billionaire during the dot-com bubble. In 2002 Seth Gilbert and Nancy Lynch of MIT published a formal proof, which elevated the conjecture to a theorem.

Quiz me

0/3

  1. 1.During a network partition, what must a distributed store choose between?
  2. 2.Which statement best matches Brewer's 2012 clarification?
  3. 3.Why does Kubernetes' etcd store favor consistency over availability?

Recap

When the network splits, you must choose: refuse to answer (consistent) or answer possibly stale (available).

💡 A trick to remember it · Two friends with one notebook and a cut phone line: either "I can't say" or "here's what I last knew".

Surprising fact · Without a partition, a system can have both consistency and availability.

Sources (3)

No source, no claim. Every fact in this lesson (15 claims) cites at least one of these.

  1. [1]CAP theorem · Wikipedia
  2. [2]Eric Brewer (scientist) · Wikipedia
  3. [3]Kubernetes · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗