System Design · Concept Library · Free article
The CAP Theorem — What a Network Split Forces You to Give Up
Once the network splits a distributed system in two, you can keep it consistent or keep it available — not both, until the split heals. Why "pick 2 of 3" is the wrong way to say it, what the C in CAP really means (linearizability, not ACID), how real systems choose and degrade, and the latency-vs-consistency tradeoff (PACELC) that matters even when nothing is broken — for interns through principal engineers.
The CAP theorem says that the moment a network partition splits your replicas, you must choose: keep the system consistent (every read sees the latest write, or gets an error) or keep it available (every node keeps answering, possibly with stale data) — you cannot have both while the split lasts. The famous "pick 2 of 3 — Consistency, Availability, Partition-tolerance" is misleading, because on a real network you never actually choose P: messages get dropped whether you like it or not, so partitions are a fact, not an option. That leaves the only real choice — C or A — and only during a partition; the rest of the time you can have both. Two more things every senior misses: CAP's "C" is a narrow, precise guarantee called linearizability (a single-copy illusion — a read sees the latest write in real time), which is not the C in ACID; and the tradeoff you actually tune every day, even with a perfectly healthy network, is latency versus consistency (the PACELC extension) — because keeping replicas in sync costs a round trip. CP systems (etcd, ZooKeeper, HBase, Spanner) stop serving the minority side to stay correct; AP systems (Cassandra, DynamoDB, Riak) keep answering and reconcile later. There is no "CA" system on a real network — that's a bet that a partition never happens, not a design that survives one.
An ocean away, a fan reads a link that just changed
It’s 21:00 in Tokyo. A creator in New York just repointed one of their Hatch links — an hour ago it went to the old landing page, now it should go to tonight’s launch. Hatch keeps a copy of the link database on each side of the Pacific so reads are fast: New York writes to the US replica, Tokyo reads from the APAC replica, and the two normally stay in step within a heartbeat. Then, mid-evening, an undersea cable cuts. For the next few minutes the two replicas are both alive and both serving — but they cannot hear each other at all.
Now a fan in Tokyo taps that link. The APAC replica has a value for it — but it’s the old one, from before New York’s change, and APAC has no way to reach across the dead cable to check whether it’s still current. So the system faces a fork with exactly two branches and no third: serve the fan the stale link instantly (fast, but wrong), or refuse to answer until the cable heals (correct, but the fan gets a spinner). That’s it. There is no option that is both instant and guaranteed-fresh, because the only machine that knows the fresh value is unreachable. This little dilemma, made precise and proven unavoidable, is the CAP theorem — and by the end of this page you’ll know exactly which branch to take for a link, for a like, and for a bank balance.
C, A, and P — in plain words first
CAP is three promises a distributed data store might try to make. In plain words: Consistency means every read sees the most recent write — no matter which replica answers, you get the latest value (or an honest error). Availability means every request to a working replica gets a real answer back, never a spinner or a failure. Partition tolerance means the system keeps functioning even when the network between replicas drops or delays messages — a cut cable, a flaky link, a lost packet storm. The theorem is about what happens when you try to hold all three at once.
Hold on to the precise versions too, because the loose ones cause half the confusion in interviews. CAP’s C is not the "C" in ACID — it isn’t about enforcing constraints or valid transactions; it’s specifically that the whole replicated system behaves as if there were a single copy of the data that everyone reads and writes in real-time order (the formal name is linearizability, and a later section makes it exact). CAP’s A is strict: every request to a non-failing node must return a non-error response — and notably with no promise about speed, so "slow but eventually answers" still counts as available. And P doesn’t mean "handles partitions gracefully" — it means the system’s guarantees are expected to survive a network that can lose arbitrarily many messages. Keep these close; we’ll lean on all three.
You don’t pick 2 of 3 — you pick C or A when the split hits
The slogan everyone repeats is "pick two of Consistency, Availability, Partition tolerance." It’s catchy and it’s misleading, because it makes P sound like a menu item you can decline. You can’t. On any real network spanning machines — let alone oceans — messages will be lost or delayed sometimes. Partitions are not a design choice; they are weather. So "dropping P" isn’t a real option: a distributed system that hasn’t planned for a partition simply breaks when one arrives, rather than choosing anything.
Once you accept that P is mandatory, the theorem says something much sharper: when a partition is happening, you must give up either C or A. Either a replica that can’t confirm it has the latest data refuses to answer (you keep C, you lose A), or it answers with what it has and risks being stale (you keep A, you lose C). And here is the part the slogan hides: this trade only bites during the partition. When the network is healthy, a well-built system delivers both consistency and availability at once — the sacrifice is the exception, not the steady state. Feel the fork directly: cut the cable, change the value on one side, and choose what the far replica does when a reader shows up.
The interactive version of this example is available when JavaScript loads.
There is no "CA" system on a real network
People love to fill in the third corner: "well, my database is CA — consistent and available, I just don’t tolerate partitions." It sounds reasonable and it’s a trap. Saying you’re "CA" doesn’t buy you a partition-proof system; it just means you haven’t decided what to do when a partition happens — and one eventually will. At that moment the choice arrives whether you planned for it or not, and an unprepared system doesn’t magically stay both consistent and available: it corrupts, stalls, or splits. "CA" isn’t a third option; it’s a bet that the network never fails, paid out in outages when it does.
The only place "CA" honestly applies is a system that isn’t distributed in the first place — a single database on a single machine. With one node there’s no network between replicas to partition, so consistency and availability don’t trade off. But that’s a statement about not being distributed, not a clever way to beat CAP. The moment you add a second replica across a network for durability or scale — which is the whole reason we’re here — a partition becomes possible, and you’re back to choosing C or A. So in practice every distributed store is either CP or AP: it has decided, in advance, which one it gives up when the split comes. The rest of this page is about making that decision well.
CP and AP — and how each one bends under a split
Since every distributed store has to pre-commit to a side, systems sort into two camps by which letter they defend when a partition hits. A CP store keeps Consistency and gives up Availability: the side that can’t be sure it’s current stops serving rather than risk a wrong answer. An AP store keeps Availability and gives up Consistency: every replica keeps answering with whatever it has, and the divergence gets cleaned up after the network heals. Neither is "better" — they’re answers to different questions about what’s worse for your users: a stale answer, or no answer.
CP systems are the ones you met in the consensus chapter: etcd, ZooKeeper, HBase, Google Spanner — all leader-and-quorum designs. When a partition strikes, the minority side can’t reach a quorum, so it stops serving: it rejects writes, and it won’t answer a read it can’t prove is current either. It would rather be down than wrong. Watch that second half — it’s the subtle bit: if the minority instead kept answering reads from its own local copy, those reads could be stale, and serving stale data to stay up is an availability choice, not a consistency one. A true CP node refuses rather than risk it. That strictness is exactly what you want for the small, must-agree state a system is built around: who holds a lock, which node is the leader, the current config, a bank ledger. When "wrong" is catastrophic, choose CP and eat the downtime.
AP systems are the Dynamo-style leaderless stores: Cassandra, DynamoDB, Riak. There’s no single leader to lose, so every replica just keeps taking reads and writes on its own side of the split, and the system reconciles the diverged copies once the cable is back. That’s the right call when being down is worse than being briefly stale: a social feed, a shopping cart, a like count, a stream of device telemetry. Nobody quits your app because a like count was off by one for ten seconds; plenty quit because it wouldn’t load.
Now the part references skip: how each camp actually bends, because "choose A" is a slogan until you’ve seen the machinery. A CP system degrades by fencing off the minority: it returns errors for writes and for any read that must be current, so that side simply goes dark. Some CP stores add an explicit escape hatch — a follower read flagged "possibly stale" — but using it means opting out of C for that one query, trading consistency for availability read-by-read; the default stays strict. An AP system degrades the opposite way, by absorbing the writes both sides take: it stashes writes destined for unreachable replicas (hinted handoff) and relaxes how many copies must ack (a sloppy quorum), then on heal it reconciles conflicts — either last-write-wins (simple, but it silently drops one of two concurrent writes) or a conflict-free merge (a CRDT, which merges both without loss for the right data types). The table pins the two camps side by side:
| Under a partition… | CP (consistency-first) | AP (availability-first) |
|---|---|---|
| What it gives up | Availability — the unsure side stops serving | Consistency — replicas may serve stale, diverging data |
| Typical design | Leader + quorum (Raft / ZAB / Paxos) | Leaderless, Dynamo-style replication |
| Example systems | etcd, ZooKeeper, HBase, Spanner | Cassandra, DynamoDB, Riak |
| How it degrades | Minority refuses writes and current reads (goes dark); a "possibly-stale" read is an explicit opt-out of C | Both sides keep writing; hinted handoff + sloppy quorum absorb it |
| On heal | Minority rejoins and catches up — nothing to reconcile | Reconcile conflicts: last-write-wins (lossy) or CRDT merge (lossless) |
| Reach for it when | A wrong answer is catastrophic: locks, leader, config, ledgers | Being down is worse than briefly stale: feeds, carts, likes, telemetry |
What "consistency" actually means here: linearizability
Time to make the "C" exact, because the loose version — "all the replicas have the same data" — is what trips up nine interview answers out of ten. CAP’s consistency is a specific, strong guarantee called linearizability, and the cleanest way to hold it in your head is the single-copy illusion: however many replicas actually exist, the whole system behaves as if there were exactly one copy of the data that everyone reads and writes, in real-time order. Concretely, that means once a write completes, every read that starts afterward must see that write (or a newer one) — no reader can travel back in time to a value that’s already been superseded. It’s a promise about recency, per object, measured against the real-world clock.
And here is the correction worth memorizing: CAP’s C is not the C in ACID. ACID’s consistency is about a transaction leaving the database in a valid state — constraints hold, invariants respected, no half-applied transfers. CAP’s consistency is about recency across replicas — did your read see the newest write? They’re different axes entirely; a system can have one without the other. When an interviewer asks "what does the C in CAP mean," the difference between "all nodes agree" and "linearizability — the single-copy illusion, and no, not the ACID C" is the difference between a junior and a senior answer.
Linearizability is also just the top of a ladder. Below it sit weaker, cheaper, more-available consistency levels — sequential, causal, eventual — each giving up a little more recency in exchange for staying up and staying fast under a partition. This matters enormously for CAP, because the theorem’s "C" refers only to the very top rung. Everything below linearizability is invisible to CAP — a system can be highly "consistent" in a weaker, perfectly useful sense and still count as giving up C. Slide down the ladder and watch the tradeoff move:
The interactive version of this example is available when JavaScript loads.
The two-node proof, in plain words
CAP isn’t a rule of thumb or an engineering tradeoff someone might out-clever with a better algorithm — it’s a theorem, proven impossible, and the proof fits in a paragraph. Take the smallest interesting system: two replicas, call them G1 and G2, holding one value. Now cut every message between them — a partition. Send a write of a new value to G1. To stay available, G1 must accept it and reply "done" — but no message can reach G2, so G2 still holds the old value. Now send a read to G2. To stay available, G2 must answer — but the only value it has is the stale one. It just returned a value older than a write that already completed. That’s a violation of linearizability. So in this one execution you cannot have both availability and consistency. One example is all a theorem needs.
Look at every way out and watch each one cost you a letter. Make G2 refuse to answer until it can reach G1? Then it’s consistent but not available. Let G2 answer with the stale value? Available but not consistent. Make the write on G1 block until G2 confirms it? During the partition that confirmation never comes, so the write hangs forever — which is just losing availability on the write side instead of the read side. There is no fourth door. As Brewer put it, a partition is really just a time bound on communication that got exceeded — and choosing to retry until the message finally gets through is choosing consistency over availability. The theorem doesn’t forbid you from trying hard; it just tells you what you’re giving up while you do.
PACELC — the tradeoff that bites even when nothing is broken
CAP has a blind spot, and once you see it you can’t unsee it: CAP only speaks about the moment of a partition. But partitions are rare — a good network is healthy the overwhelming majority of the time. So what governs your system on a normal Tuesday, when nothing is broken? CAP says nothing. PACELC fills the gap. Read it as a sentence: if there’s a Partition (P), choose Availability or Consistency (A/C) — else (E), choose Latency or Consistency (L/C). The first half is just CAP. The second half — the ELC part — is the one that actually runs your life, because it applies to every single request on a healthy network.
Why is there a latency-vs-consistency tradeoff at all when the network is fine? Because keeping replicas consistent isn’t free even in perfect conditions. To guarantee a write is seen everywhere before you call it done, the write has to wait for at least one round trip to the other replicas and hear them confirm. Skip that wait — acknowledge the instant the local replica has it and ship the copies afterward — and the write is fast, but for a little while a reader on another replica can get a stale value. That’s the whole ELC tradeoff, and no replication scheme escapes it: synchronous replication buys consistency with latency; asynchronous replication buys latency with a window of staleness. Feel the dial directly — there’s no partition here, just physics:
The interactive version of this example is available when JavaScript loads.
Now put the two halves together and every store gets a four-letter fingerprint. PA/EL systems favour availability under a partition and low latency otherwise — the Dynamo family: Cassandra, DynamoDB, Riak. PC/EC systems favour consistency in both worlds — Spanner, HBase, VoltDB, and (with majority writes) MongoDB, etcd, ZooKeeper. And the fascinating off-diagonal, PC/EL, exists too: Yahoo’s PNUTS chose consistency during a partition but latency in normal operation. Place a few systems yourself and notice which corner is crowded:
The interactive version of this example is available when JavaScript loads.
Why "MongoDB is CP" is the wrong sentence
Here’s a take that will make you sound sharper than the room: stop labelling whole databases "CP" or "AP". The reason is precise, not contrarian. CAP models exactly one consistency level (linearizability) and exactly one kind of fault (a total network partition). Real databases offer many guarantees — often selectable per query — and face many kinds of trouble: slow nodes, partial failures, crashes, dropped-but-not-partitioned messages. Squeezing all of that into two letters throws away the very information you need. A database isn’t a point on the CAP map; it’s a menu.
Watch the same database land on both sides depending on the operation. PostgreSQL under snapshot isolation is serializable but not linearizable — so it’s cleanly neither CP nor AP by CAP’s own definitions. MongoDB is "consistent" with majority writes and a linearizable read concern, but dial the concerns down and it happily serves stale reads to stay fast. ZooKeeper does linearizable writes, yet its default local reads are allowed to be stale — consistent and available in the same system, depending on which call you make. Cassandra, the poster child for AP, becomes effectively consistent for a key the moment you read and write it at QUORUM. The label depends on the operation and the config, not the logo on the box:
The interactive version of this example is available when JavaScript loads.
How to stay up without turning to mush
Choosing availability doesn’t mean shrugging and serving garbage. There’s craft to staying up and useful under a partition, and three tools do most of the work. The first is harvest and yield: instead of an all-or-nothing answer, return a partial one. If a search must fan out to 100 shards and 1 is unreachable, don’t fail — answer from the 99 you have and note the result is ~99% complete. Yield is "did you answer at all"; harvest is "how much of the data made it in." Under stress you deliberately trade a little harvest for a lot of yield — a slightly incomplete feed beats a spinner.
The second is treating a partition as a lifecycle, not a coin flip. Brewer’s own refinement of CAP is that mature systems detect the partition, enter an explicit partition mode where they limit or queue the risky operations (and record what diverged), and then run recovery when the network heals — merging the two histories and compensating for anything that can’t be silently reconciled. If a payment was provisionally accepted on both sides, you don’t just pick one; you record the intent, and settle (or refund) on heal. Detect → degrade → recover, with a plan for the mess.
The third is not dropping further down the consistency ladder than you must. The sweet spot for staying available is causal consistency: it preserves cause-before-effect (a reply never appears before its message) without any cross-network coordination, so it survives a partition while still feeling sane. And for the data types that allow it, CRDTs (conflict-free replicated data types — counters, sets, last-writer registers, even shopping carts) let both sides of a split keep writing and then merge with no conflict and no lost update on heal. That’s the gold standard of AP design: fully available, and still guaranteed to converge to a single correct answer. Reach for causal-plus-CRDT before you settle for raw last-write-wins.
Choose per operation, not per database
All of this collapses to one question you ask per operation, not per database: for this specific thing the user is doing, which is worse — a stale answer, or no answer? If a wrong answer is dangerous or irreversible, choose consistency and accept that this operation can be briefly unavailable. If being down loses users and a little staleness is harmless, choose availability and reconcile later. The same application makes both choices, dozens of times, depending on what’s at stake in each call.
| Lean consistent (tolerate downtime) | Lean available (tolerate staleness) |
|---|---|
| Moving money / a bank balance | A social feed or timeline |
| Decrementing inventory (don’t oversell) | Like, view, and follower counts |
| Claiming a unique username | A shopping cart’s contents |
| Leader election, locks, config / feature flags | Product catalog browsing |
| An order’s final "paid" state | Telemetry, logs, analytics events |
And keep the PACELC lens on even after you’ve picked a side, because the everyday question isn’t "C or A" — partitions are rare — it’s "how much latency will I spend for how much freshness?" Put strong consistency only where correctness truly demands it, let everything else be fast and eventually-correct, and you get a system that’s both trustworthy where it counts and quick everywhere else. That, not a two-letter label, is what "understanding CAP" actually buys you.
How to see which way your system actually leans
CAP is a design choice, but a choice on a slide deck and a choice your running system actually honours are two different things. In production you want to see your posture — how stale reads get, how often you go unavailable, and whether your "strong" guarantees survive a real split. A handful of signals tell the story:
| Signal | What it tells you |
|---|---|
| Replication lag / staleness window | How far behind followers run — the size of the stale-read window an AP read can hit. Rising lag = more staleness. |
| Unavailability under partition | The error/timeout rate on the fenced side during a split — the price a CP system pays to stay correct. |
| Partition frequency & duration | How often the C-vs-A choice actually fires, and for how long. Rare + short = you can afford CP; frequent = availability matters more. |
| Conflict / reconciliation rate | For AP stores: how many concurrent writes had to be merged or dropped (last-write-wins losses, CRDT merges, read-repairs). |
| Time-to-visibility | Inject a known write, then read replicas until it appears — a direct measurement of how "recent" your reads really are. |
And the honest test nobody wants to run: you do not know your CAP posture until you have partitioned the system on purpose. Cut the network in a controlled experiment (the discipline is called chaos testing; the famous public version is Jepsen) and watch what actually happens — because the graveyard of distributed systems is full of stores that claimed strong consistency and quietly lost committed writes under a real split. A guarantee you have not tested under a partition is a guarantee you do not have.
What consistency costs — and why CAP is narrower than it looks
Strong consistency is not free, and its bill comes on every strongly-consistent operation: a round trip to a quorum or the leader (and often a disk sync), which is latency now and reduced availability when the network wobbles. So the instinct to "just make everything strongly consistent to be safe" is a real mistake — it makes your system slower and less available for no benefit on the operations that never needed it. Strong consistency is a scarce resource; spend it where a wrong answer is unacceptable, and nowhere else.
And keep CAP in its lane, because it is narrower than the amount of airtime it gets suggests. The theorem covers exactly one fault (a total network partition) and exactly one consistency level (linearizability). Real life is messier: nodes that are slow rather than dead, "gray" partial failures, a replica that is up but lagging, a dozen consistency levels between linearizable and eventual. Treating every design question as a binary "CP or AP" is a junior tell; the senior move is to notice that most of your day-to-day tradeoffs are PACELC latency choices on a healthy network, not partition choices at all. CAP tells you what a split forces — it does not tell you how to design your whole system.
The landscape — real systems, honestly labelled
With the nuance in hand, here’s where the well-known stores actually land — remembering that most expose knobs to move per operation, so these are defaults and leanings, not cages.
| System | Lean | PACELC | Why / the nuance |
|---|---|---|---|
| etcd, ZooKeeper | CP | PC/EC | Consensus-backed (Raft / ZAB); the control-plane default — consistency first, both under partition and normally. |
| Google Spanner | CP | PC/EC | Consistent via TrueTime; forfeits A under a real partition, but "effectively CA" because Google engineers partitions to be rare. |
| HBase | CP | PC/EC | One region-server per region → linearizable; minority unavailable on failover. |
| Cassandra | AP | PA/EL | Leaderless; available + low-latency by default, tunable to consistent per key via QUORUM reads/writes. |
| DynamoDB | AP | PA/EL | Eventually-consistent by default; strongly-consistent reads are an opt-in that costs latency and availability. |
| Riak | AP | PA/EL | Dynamo lineage; available under partition, latency-first otherwise. |
| MongoDB | CP-leaning | PC/EC | With majority writes + linearizable reads it is CP; weaker concerns slide it toward availability. |
| Kafka | Configurable | — | No fixed letter: unclean.leader.election is the CP↔AP switch; acks=all + in-sync replicas leans CP. |
| PNUTS | CP-ish | PC/EL | The famous off-diagonal: consistent under partition, latency-optimised in normal operation. |
| PostgreSQL (single node) | "CA" | — | Not distributed, so no partition to survive — the only honest "CA", and only because there are no replicas to split. |
The tell across the table is simple: leader-and-quorum designs land CP; leaderless Dynamo-style designs land AP — and almost everyone bolts on knobs to move a given operation the other way. Learn to read a new datastore by asking "does it have a single leader / quorum, or is it leaderless?" and you can predict its partition behaviour before you read a line of its docs.
Where CAP shows up in your code: consistency knobs
You rarely "choose CAP" once in an architecture diagram. You choose it per call, through a consistency knob the client library exposes. The same database, the same table — a different flag on the read or write, and you’ve moved that operation between C and A. A few of the knobs you’ll actually type:
The consistency dials, by store
- Cassandra — a consistent read: write at
QUORUMand read atQUORUM, soW + R > Nand the read is forced to overlap the latest write. Drop the read toONEand it’s faster but can be stale — you just moved that read from C to A. - DynamoDB — a read takes
ConsistentRead: truefor a strongly-consistent result (costs latency and is refused if the item’s replicas can’t be reached), versus the default eventually-consistent read that’s cheaper and may lag. - MongoDB — pair
writeConcern: { w: "majority" }withreadConcern: "linearizable"for CP-like behaviour; switch tow: 1and a secondaryreadPreferenceand you’ve chosen availability and speed for that operation. - etcd — a normal
Getis linearizable (a quorum round trip); passWithSerializable()to read from the local member for lower latency and possibly-stale data — the same store, opted out of C for that call.
Pitfalls
- Thinking you can "drop P" and be CA. On a real network partitions happen whether you planned for them or not; "CA" just means you haven’t decided what to do when one hits. The only honest CA is a single non-distributed node.
- Conflating CAP’s C with ACID’s C. CAP’s C is linearizability (real-time recency across replicas); ACID’s C is transaction validity (constraints hold). Different axes — mixing them up is the classic interview stumble.
- *Believing a majority write gives consistent reads.* It doesn’t on its own — a read from a lagging replica is still stale. Consistency needs the read to overlap the write (a quorum read,
W + R > N, or a confirmed-leader read). - Labelling a whole database "CP" or "AP". CAP describes an operation under a partition, not a product. The same store is consistent-like or available-like per operation and per config.
- Making everything strongly consistent "to be safe." Strong consistency costs a round trip (latency) and availability on every op; spend it only where a wrong answer is unacceptable.
- Ignoring PACELC. Obsessing over the rare partition while unconsciously making the latency-vs-consistency choice on every request — which is the tradeoff that actually shapes day-to-day behaviour.
- Trusting a guarantee you haven’t partition-tested. Plenty of systems claimed strong consistency and lost committed data under a real split. If you haven’t chaos-/Jepsen-tested it, you don’t have it.
- Assuming AP means no data loss. Naive last-write-wins silently drops one of two concurrent writes. If you need both, use CRDTs or explicit conflict resolution, not LWW.
- Calling Spanner a CAP counterexample. It’s CP and forfeits A under a real partition; it just makes partitions rare enough to feel CA. Rare ≠ impossible.
Best practices
- Decide per operation, not per system. For each call ask: "is a stale answer or no answer worse here?" — and route it accordingly.
- Spend consistency where correctness demands it (money, inventory, uniqueness, locks, leadership, config) and let everything else (feeds, counts, carts, catalogs, telemetry) stay available and eventually-correct.
- Say the guarantee, not the letter. "This write waits for a majority and this read is linearizable" beats "we use a CP database" every time.
- For a consistent read, overlap the write — read a quorum (
W + R > N) or the confirmed leader; never read an arbitrary lagging follower and call it consistent. - On the AP side, prefer causal consistency + CRDTs over raw last-write-wins; pair with hinted handoff and a reconcile-on-heal step that compensates for anything that mustn’t be lost.
- Keep the PACELC lens on. Most days there’s no partition — the live question is how much latency you’ll pay for freshness. Default to fast-and-eventual, upgrade specific operations to strong.
- Test under partition. Chaos-test (or read the Jepsen report) before you trust a store’s consistency claims in a design.
- Design an explicit partition lifecycle for critical flows: detect → enter a limited partition mode → reconcile and compensate on heal.
From intern to principal, the questions you’ll get
- What do C, A, and P stand for? (intern)
- Consistency (a read sees the latest write, or an error), Availability (every working replica returns a non-error answer), Partition tolerance (the system keeps working when the network drops messages between nodes).
- If you can only pick two, which do you drop? (SDE1)
- Trick question. On a real network you can’t drop P — partitions happen whether you like it or not. So the real choice is only during a partition: consistency or availability. The rest of the time you can have both.
- Give a CP system and an AP system, and why. (SDE2)
- CP: etcd / ZooKeeper — the minority side stops serving under a partition to avoid a wrong answer; you need that for locks, leader election, config. AP: Cassandra / DynamoDB — every node keeps answering with possibly-stale data; you want that for feeds, carts, counts, where down is worse than briefly stale.
- Can you have a CA system? (SDE2)
- Not as a runtime guarantee on a distributed system. "CA" describes a single node with no replicas to split, or a system that simply hasn’t decided what to do under a partition — and one will eventually happen, forcing it back to C or A.
- What does the C in CAP actually mean? (SDE3)
- Linearizability: the whole replicated system behaves as if there were one copy, and a read that starts after a write completes sees that write (or newer) — a real-time recency guarantee per object. It is NOT ACID’s consistency (transaction validity). Saying "linearizability, not the ACID C" is the senior answer.
- Does writing to a majority make reads consistent? (SDE3 → staff)
- No — not on its own. A read served from a replica that hasn’t caught up is still stale. Consistency comes from the read overlapping the write: read a quorum so
W + R > N(the read set must share a node holding the latest write), or read from the confirmed leader. Reading an arbitrary follower for speed is an availability choice. - What is PACELC? (staff)
- An extension of CAP: if there’s a Partition, choose Availability or Consistency; Else (normal operation), choose Latency or Consistency. The ELC half is the one that matters daily — keeping replicas consistent costs a round trip, so consistency and latency trade off even with no partition. Cassandra = PA/EL, Spanner = PC/EC, PNUTS = PC/EL.
- Is Kafka CP or AP? (staff)
- "It depends on the config." With
acks=all,min.insync.replicas > 1, and unclean leader election disabled, it leans CP (becomes unavailable rather than lose committed data). Enableunclean.leader.electionand it trades toward AP and can lose committed messages. That flag is the CP↔AP switch. - Why does Kleppmann say to stop calling databases CP or AP? (staff → principal)
- Because CAP models only one consistency level (linearizability) and one fault (a total partition), while real databases offer many guarantees per operation and face many faults. So most (Postgres, Mongo, ZooKeeper) fit neither box cleanly. Describe the per-operation guarantee instead of stamping one label on the whole store.
- Is Spanner a counterexample to CAP? (principal)
- No. Spanner is CP — under a real partition it forfeits availability. It’s "effectively CA" only because Google engineered partitions to be extremely rare (a private global network plus TrueTime). Driving down the probability of a partition isn’t the same as beating the impossibility result.
- Design a system that stays available under a partition. (principal)
- Choose AP with the strongest usable consistency: leaderless replication with quorums tuned for availability, causal consistency where ordering matters, CRDTs for conflict-free convergent state (counters, sets, carts), hinted handoff / sloppy quorum to absorb writes for down nodes, and a detect → partition-mode → reconcile-on-heal lifecycle that compensates for anything that must not be lost (e.g. record a payment’s intent and settle after recovery). State the ELC latency choice explicitly.
A split forces a choice — make it on purpose
Nearby: Raft & Leader Election is the CP machinery — how a system stays consistent under a partition by making the minority stand down; Read/Write Quorums is the overlap rule (W + R > N) that turns "reached a majority" into an actual consistency guarantee; Leader–Follower Replication is where the sync-vs-async choice — the ELC dial made concrete — lives; and Latency & the Speed of Light is why keeping replicas consistent across regions costs what it costs. And the wound this opens: everything here assumed a partition is a rare accident — but once your replicas are spread across continents, the "round trip to agree" is a permanent tax on every strongly-consistent write, and designing around that is where the journey heads next.
By GOAT Engineer. Back to Concept Library. Privacy Policy · Contact.