ML
Scaling

CAP Theorem: What It Actually Says (and What It Doesn't)

Consistency, Availability, Partition-tolerance — pick two. That summary is almost useless. Here's the real version.

April 22, 20257 min readScalingDistributed Systems

CAP is the most-cited and most-misquoted theorem in distributed systems. The real statement: during a network partition, a system must choose between responding consistently or responding at all. Outside of a partition, you get both.

The three letters

  • C — Consistency (linearizability). Every read sees the most recent committed write. Not the same as ACID's C.
  • A — Availability. Every non-failing node responds to every request (with a non-error answer).
  • P — Partition tolerance. The system keeps working when the network drops messages between nodes.

The "pick two" is misleading

You don't get to opt out of P. Networks partition. Cables fail, switches reboot, cloud zones lose connectivity. So in practice: when a partition happens, do you want the C or the A behaviour?

  • CP systems (Postgres with sync replication, etcd, ZooKeeper, HBase) — during a partition the minority side stops accepting writes. You'd rather return an error than a stale answer.
  • AP systems (Cassandra, DynamoDB in default mode, Riak) — during a partition both sides keep serving. You'll reconcile divergent writes later.

Outside of partitions: PACELC

The more complete framing (Abadi, 2012): If there's a Partition, trade Availability vs Consistency; Else trade Latency vs Consistency. Most "eventually consistent" stores are PA/EL — they accept latency cost in exchange for availability under partition and lower latency when healthy.

Practical consequences

  • Choosing a database is choosing a partition behaviour. Read the docs, not the marketing page.
  • Quorum configs (e.g. W=2, R=2, N=3 in Dynamo-style systems) let you tune where on the spectrum you sit — per-operation, even.
  • "Eventually consistent" does not mean "soon." It means "correct after the partition heals, assuming no new conflicts." Application code must handle reading its own stale writes.

The rule of thumb

Financial, inventory, correctness-critical → CP. Shopping carts, social feeds, analytics → AP. Mixed workload → two databases, one for each property, with clean boundaries. Don't fight a database's native behaviour.

SharePostLinkedIn

Reader Discussion

7 replies// weighed in

TopNewestAuthor
Add to the thread
Disagree, agree harder, or share your own experience…
Email instead →markdown okbe kind
  1. Highlighted by author
    Evan Whitfield· Eng DirectorStory

    "scale vertical until it becomes awkward" — yes. We sunk SIX MONTHS into a sharding project that a $4k/month bigger box would have made unnecessary for two more years. Premature distribution is the bourgeois cousin of premature optimisation.

    Apr 24, 2025·2 days later
  2. Grace Liu· Senior EngineerFrom experience

    idempotency keys are such a small API change for such a huge reliability win. ship them on every new POST endpoint as a default. the day you need them and don't have them is one of the worst days of your career.

    Apr 25, 2025·3 days later
  3. Kofi Mensah· Infra EngineerAsks

    Q: idempotency-key table — keep on primary or shard it? we hit ~120M rows/month and the index is bigger than the data. partition by month + retention helps but I'm curious what others do

    Apr 27, 2025·5 days later
  4. Monique Laurent· Principal EngineerFrom experience

    cell-based architecture is how you sleep at night past a certain scale. blast-radius math is so much friendlier when one cell going down hurts 1/N customers instead of all of them. it's also 2x ops cost — pick your poison.

    Apr 28, 2025·6 days later
  5. Quốc Anh🇸🇬 SG· Cloud ArchitectAgrees

    PACELC > CAP. Once you accept that partitions aren't the only trade-off (latency-vs-consistency happens 24/7, partitions are a side quest), the whole topology debate gets clearer. Wish PACELC had CAP's branding budget.

    Apr 26, 2025·4 days later
  6. Léa Dubois· SREAsks

    any chance you'd publish these as a PDF collection? would love to print and read offline on flights. screen-fatigue is real.

    Apr 28, 2025·6 days later
  7. Ahmed Rahman· Full StackKind words

    concise + opinionated = my favourite kind of engineering post. so many blogs hedge every claim into mush. give me the spicy take with the receipts. more please.

    Apr 23, 2025·1 day later

Worked on something similar? Email ducminhldm@gmail.com — I read every one. The good ones become future posts.

Comments seeded · live discussion via email