Menu

1 / 2

📐 CAP Theorem Explained Like You're 5

DEV Community·Sreekar Reddy·6 months ago
#CSEO3vMb
Reading 0:00
15s threshold

Pick two: consistency, availability, partition tolerance

Day 124 of 149

👉 Full deep-dive with code examples

The Three Wishes Analogy

A genie says: "Pick any TWO wishes, but not all three"

Wish 1: Fastest car

Wish 2: Cheapest car

Wish 3: Most reliable car

You can have fast + cheap (less reliable), or cheap + reliable (not fast).

CAP is like this—but the real trade-off shows up when the network is split (a partition).

The Three Properties

C - Consistency:

Reads behave as if there were a single up-to-date copy (strong consistency)

In practice, “consistency” has levels; CAP discussions usually mean a very strong form

A - Availability:

Every request gets a response from a non-failing node

That response might be an error (the key point is: the system doesn’t stop responding)

P - Partition Tolerance:

The system keeps operating even if messages between servers are dropped/delayed (a network partition)

Why You Can't Have All Three

Imagine two servers that should stay in sync:

Server A ←─ network…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.