System Design Playbook
08 · Data & databases7 min read

The CAP theorem and eventual consistency, without the jargon

When the network between two copies of your data breaks, you must choose: refuse requests to stay correct, or keep answering and fix the differences later.

In one sentence

When a network partition splits your replicas, a system can stay Consistent (refuse what it can't answer correctly) or Available (answer anyway, maybe with old data). It can't do both until the network heals.

C, A and P in plain words

  • Consistency: every read sees the latest write. Everyone sees the same data at the same time.
  • Availability: every request to a working node gets an answer (not an error), even if it's not the latest data.
  • Partition tolerance: the system keeps working when messages between nodes are lost or delayed.

The usual "pick two out of three" is misleading. In a distributed system partitions will happen (a cable, a cloud zone, a misconfigured firewall), so P isn't optional. The real question is: during a partition, do you prefer C or A?

Try it: cut the network

Two replicas of Ana's profile, one in Madrid and one in New York. Cut the network, write on one side and read from the other. Then switch between CP and AP and repeat.

A network partition: consistency or availability?
When the network fails
replicationMadridbio v1New Yorkbio v1CLIENT · AnaCLIENT · Ben
Successful requests
0
Errors
0
Stale reads
0
Replicas agree?
yes
AP systems keep answering on both sides and reconcile later. Good for likes, feeds and profiles, where a few seconds of disagreement is fine.
In CP mode, requests fail during the partition. In AP mode they succeed, but New York can serve an old version, and edits on both sides end in a conflict.

CP or AP: it depends on the data

Choose consistency (CP)

  • Bank balances, payments, stock
  • Seat or ticket bookings
  • Usernames that must be unique
  • Users see errors during failures, never wrong data

Choose availability (AP)

  • Likes, view counts, feeds
  • Shopping carts, profiles, presence
  • DNS and caches
  • Users always get an answer; it may be a few seconds old

A single app usually needs both. In a ticketing app, the seat map can be AP (slightly stale availability is fine), but the final booking must be CP: two people can't buy the same seat.

Eventual consistency and conflicts

AP systems promise eventual consistency: if writes stop, all replicas end up with the same data. Usually within milliseconds; during a partition, as soon as the network heals.

If both sides were written during the partition, there's a conflict. Common ways to resolve it:

StrategyHowCost
Last write winsKeep the version with the latest timestampSimple, but silently loses the other edit
MergeCombine both (e.g. union of two shopping carts)Needs data that can be merged (CRDTs)
Ask the userShow both versionsHonest, but extra work for the user

Beyond CAP: latency (PACELC)

CAP only talks about failures. Most of the time the network is fine, and there's still a trade-off: waiting for every replica to confirm a write makes it consistent but slower. PACELC summarizes it: if Partition, choose A or C; Else, choose Latency or Consistency.

That's why many databases let you choose per query: DynamoDB has eventually consistent and strongly consistent reads; Cassandra lets you pick how many replicas must answer (ONE, QUORUM, ALL).

Key takeaways

  • 01Partitions happen, so the real choice is consistency or availability while they last.
  • 02CP refuses requests it can't answer correctly; AP answers anyway and reconciles later.
  • 03Pick per feature: money and bookings CP, feeds and counters AP.
  • 04Eventual consistency needs a conflict strategy: last write wins, merge or ask the user.

Check your understanding

1 of 3

During a network partition, what must a distributed system choose between?

Related concepts