advancedbig-data

CAP Theorem

In a distributed system, you can't have perfect consistency, availability, and network reliability all at once.

Key Points

What it is

The CAP theorem states that a distributed data system can only guarantee two out of three properties at the same time: Consistency (every read gets the latest write), Availability (every request gets a response, even if not the latest data), and Partition Tolerance (the system keeps working despite network failures between nodes).

Why it exists

Distributed systems run across multiple machines connected by an unreliable network — messages can be delayed or lost. CAP theorem exists as a proven, formal way of explaining why no distributed system can simultaneously guarantee perfectly up-to-date data everywhere and instant responses everywhere, once network problems happen — it names the fundamental trade-off engineers must consciously choose.

Intuition

Imagine two bank branches in different cities that must stay in sync. If the phone line between them goes down (a network partition), each branch has two choices: stop processing withdrawals until the line is restored (choosing Consistency over Availability), or keep processing withdrawals independently and risk the two branches' balances disagreeing until the line is fixed (choosing Availability over Consistency). CAP theorem says you must pick one when the line is down — you can't have both.

When to use

When not to use

Common mistakes

In practice

A foundational concept for choosing and reasoning about databases in any data platform architecture — explains why a social media feed can tolerate slightly stale data (AP) while a payment ledger cannot (CP).

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

nosql-databasesdata-replication-fault-tolerancedistributed-computing-basics
Chirp at me!