CAP & Consistency in Plain Words
Before this, it helps to know: Replication & Sharding.
Read a little, play a little. No scary maths, and no rush.
The undersea cable snaps
Your database runs in Mumbai and Singapore. One day the link between them cuts. A user in Mumbai updates their profile; a user in Singapore reads it a second later. The network is split — a partition — and now you must choose: refuse the Mumbai write until the link heals (consistency), or accept it and let Singapore lag behind (availability)? You cannot have both. That forced choice is the CAP theorem, and partitions are not hypothetical — they happen to every network, regularly.
The three letters, honestly
- Consistency: everyone sees the same data, everywhere, immediately.
- Availability: every request gets an answer (even if slightly stale).
- Partition tolerance: the system keeps working when the network splits.
Since partitions are inevitable, you're really choosing between C and A during a partition. The rest of the time you can have all three and shouldn't overthink it.
Match the guarantee to the money
- Bank balance, seat booking, inventory: pick CP (consistency). Showing two people the "same" last concert ticket and selling it twice is a lawsuit, not a bug.
- Likes, feeds, view counts: pick AP (availability). Nobody sues over a like count that's 30 seconds stale — the data converges shortly after (eventual consistency).
The vocabulary that follows
Once you've chosen, the tools have names: quorums (write to 2 of 3 replicas and call it consistent enough), version vectors (track who saw what to merge later), CRDTs (data structures designed to merge without conflicts). You don't need their internals for a beginner interview — but saying "likes can be eventually consistent, balances cannot" already puts you ahead of most candidates.
A worked example: the last ticket
A concert has one seat left. Ticket servers run in Mumbai and Singapore, and the link between them has just failed. A fan in each city clicks "buy" at the same moment.
- Choose consistency (CP): the Singapore server cannot confirm that Mumbai has not already sold the seat, so it refuses the sale with "please try again shortly." One fan is disappointed for a minute, and nobody is sold a seat that does not exist.
- Choose availability (AP): both servers sell the seat. Both fans are happy until the link heals and the system discovers one seat sold twice. Someone now needs a refund and an apology.
Neither choice is free. The design question is which failure your business can live with for this particular data.
Even without a partition
CAP only describes behavior during a network split. A useful extension, PACELC, adds the everyday case: else, when the network is fine, you still trade latency against consistency. Waiting for replicas in other regions to confirm every write keeps data consistent but makes each write slower. Many global systems accept slightly stale reads precisely to stay fast.
Choosing per request
Consistency is often not one setting for a whole database. Many systems let you choose per query: a strong read for the account balance on the payment page, and a cheaper, possibly stale read for the same balance shown in a dashboard. Matching the guarantee to the request is more practical than picking one for everything.
Remember this
- Partitions force a choice: consistency or availability. Say which, and for what data.
- Money = strong consistency. Social counts = eventual is fine.
Check your understanding
5 questions · first-try answers earn the most XP
My notes
Saved in this browser. Highlight a line above and save it, or write it in your own words.
Nothing saved yet. Your highlights will live here.
References
Finished reading?
Ticking it here also ticks the chapter in the sidebar, the section count and your streak — it is all one number.
Practice this in an incident
Try a design drill
Related chapters
Spotted a mistake or want a topic covered? Report an issue