CAP, PACELC, and what they actually say
Read first: Replication
During a partition you cannot offer every live node a linearizable answer. Partition tolerance is the situation a real network already hands you, so the choice is whether a live side answers or refuses. On a healthy day you still trade latency for consistency, which is the else branch of PACELC.
A partition is a stretch of time when live machines cannot exchange messages. Requests are still arriving. You have to decide, before that day, which of those requests a lone side is allowed to finish.
Core concepts
Brewer named CAP. Gilbert and Lynch proved the claim that matters, and they proved it in the asynchronous model: messages can be delayed for an arbitrary time, and a quiet peer is indistinguishable from a dead one. In that model, during a partition, you cannot have both linearizability and a response from every live node.
Linearizability, defined properly on the next page, means a register behaves like one copy, and each operation takes effect at a single moment between when it started and when it finished. Availability, in the theorem, means something strict. A request that reaches a node which has not crashed receives a response. It does not mean “the dashboard was green” and it does not mean a 99.9% target over a month.
Why “pick two” is a sloppy slogan
The triangle on the whiteboard says you choose two of consistency, availability, and partition tolerance. That slogan is where interviews go wrong.
Partition tolerance is not a feature you can decline. Packets get lost, links get cut, a region stops answering. On a real network the partition is coming. CA, the corner that keeps consistency and availability by assuming partitions do not happen, is an assumption about the network, not a system you can deploy across a wide area. The choice CAP actually gives you is what you do once the partition has started. Either a live node refuses some requests, or it answers in a way that may not be linearizable.
The letters are also narrower than the slogan. The C in the proof is linearizability, not “we validate inputs,” and not the C in ACID. ACID consistency means the invariants of a transaction hold. You can have perfect local invariants and still serve a stale replica.
The slogan also freezes a temporary behavior into a permanent identity. Plenty of systems are linearizable for an operation until the partition, and only then pick a side. Calling the whole product CP or AP hides which operation you meant.
Two operations, two choices
A lock service is the CP pattern. Granting the lock has to look like one copy, or two clients both enter the critical section. If the service cannot finish the protocol with a majority of its replicas, it does not grant the lock. The side that cannot reach the others returns an error even though the process is up. That is the theorem’s loss of availability. Chubby, in the Bigtable design, is a lock service that holds the master lease. The idea to copy is the refusal, not a tour of Chubby’s code. Replication already told you the failure mode on the other side of this choice: two primaries is split brain, and failover needs a fence so the old primary stops accepting writes.
A shopping cart is the AP pattern. Amazon’s Dynamo paper set the goal in one line: the cart stays writable during a partition. An add that reaches one side is kept. When the sides can talk again, they reconcile. Dropping the add because the other region was silent is the outcome that design refuses. The bill is concurrent versions, and the client has to merge them. That paper is Dynamo. It is not DynamoDB, which came later and made different choices. The full writeup is on the Dynamo page.
You can run both patterns in one checkout. The cart line and the last unit of inventory are different promises. Putting them in one box labeled AP is how you sell the same unit twice, or how you refuse to remember what the shopper picked.
The else branch
Daniel Abadi’s PACELC adds the day when nothing is broken. If there is a partition (P), you trade availability against consistency (A or C). Else (E), even while the network is healthy, you trade latency against consistency (L or C).
The else branch is most of your traffic. A write that waits for a replica in another region pays the round trip on every request, partition or not. A read that answers from the local replica returns in a fraction of a millisecond and can be stale. Latency numbers are the units of that trade. Synchronous replication stalls the write on a slow replica. Asynchronous replication answers now and can lose the tail if you fail over. Neither sentence required a partition. PACELC is what stops you from treating CAP as a disaster-only theorem.
Spanner sits on the C side of the else branch on purpose. Commit wait holds a commit until the chosen timestamp is definitely in the past, so commit order agrees with real time. You pay milliseconds of clock uncertainty, and you pay the operational cost of the clocks. That system is a production story of its own. Naming it in a design interview does not answer which side of PACELC you took.
A worked example
You are sketching checkout for a store with two regions, east and west. State the assumptions out loud.
- The regions are about 4,000 km apart by fiber. Light in fiber is about 200 km per millisecond, so the one-way floor is 20 ms and the round trip is about 40 ms before routers. You assume a planning round trip of 60 ms, inside the usual coast-to-coast band of tens of milliseconds. That 60 ms is an assumption, not a measurement of one provider.
- Inventory is three replicas: one in east, one in west, and a witness in a third site. A reservation commits only when a majority, 2 of 3, has stored it. That majority is the same idea as a consensus commit, shrunk to one record.
- The partition you are designing for isolates east from both west and the witness. West can still reach the witness. This shape is an assumption about the cut, not the only way a partition can look.
- The cart is stored in the shopper’s region and does not wait for the other region.
- Volume, so the blast radius is a number: you assume 1,000,000 checkouts a day. That is the interview shortcut, not a measured store.
1 day = 86,400 seconds
shortcut: a day is about 10^5 seconds
1,000,000 / 86,400 = 11.57, about 12 checkouts per second
fiber: 4,000 km / 200 km per ms = 20 ms one way
round trip floor = 40 ms
assumed planning RTT = 60 ms
majority = 2 of 3
east can reach 1 of 3 during this partition
east cannot commit a reservation
assumed partition length = 5 minutes
5 * 60 * 12 = 3,600 checkouts on the minority side
assumed refusal timeout = 3 * 60 ms = 180 ms
then the reservation fails closed
Walk one shopper in east who clicks pay on the last unit of a lamp.
The cart write lands on the east replica and returns. You kept the intent. That is the AP choice, and it does not need the 60 ms trip.
The reservation does not land. East can store the attempt locally and cannot get a second replica. You wait past one healthy round trip before you call it a partition. Assume three planned round trips, 3 times 60 ms, which is 180 ms, and then fail the reservation. The button becomes an error, not a receipt. West and the witness still form a majority, so a shopper in west can buy that last lamp while east is refused. When the partition heals, east learns the unit is gone. The east cart still has the line, and the retry tells the shopper the truth.
Three thousand six hundred minority-side checkouts in five minutes is the size of the refusal. Each one is a person who saw an error instead of a second owner of the same lamp.
Now run the bad version, so the symptom has a name. East treats inventory like the cart and confirms the lamp without a majority. West does the same with the witness. Two receipts, one lamp. The conflict shows up in the warehouse, which is the most expensive place to merge. The cart was allowed to keep both intents. The stock count was not.
On a healthy day the same split is PACELC’s else branch. The reservation waits about 60 ms for a second replica. The cart write stays local: Dean’s same-datacenter round trip is 0.5 ms, and a cross-zone trip inside one region is often around a millisecond. You spent the fiber round trip on the operation that must not double-apply, and you refused to spend it on the operation that only has to remember a preference. Sixty divided by one half is 120. One cross-country confirmation costs about as much as 120 in-building round trips. That ratio is why the else branch belongs in the design and not in a postmortem.
flowchart TB
shopper[Shopper in east]
east[East checkout]
cart[Cart write succeeds]
reserve[Reservation fails closed]
west[West and the witness]
sold[West can still commit]
shopper --> east
east --> cart
east --> reserve
west --> sold
The diagram is the partition policy. Cart and inventory leave the same click and go to different fates. If you cannot point at which arrow refuses, you have a slogan and not a design.
Tradeoffs
| Choice | When you take it | What the user pays |
|---|---|---|
| Refuse without a majority | Locks, inventory, money | Live nodes on the minority side error |
| Accept on the reachable side | Carts, drafts, preferences | Conflicts to merge after the heal |
| Wait for the remote replica while healthy | A read or write that must match the other region | A coast-to-coast round trip on the success path |
| Answer from the local replica while healthy | Feeds, counters, product copy | Stale reads, bounded by replication lag |
| Synchronous cross-region replication | You cannot lose a committed write at failover | Every write stalls on the slow replica |
| Asynchronous replication | The write must return in-region | Failover can lose the tail |
The row you pick can differ by key. A design that picks one row for the whole product is the slogan again.
Pitfalls
- Reciting “pick two” and sitting down. The interviewer asked what a live node does during the cut.
- Treating partition tolerance as optional because your cloud provider “has a redundant network.”
- Using the ACID meaning of consistency to answer a CAP question, or the reverse.
- Giving the cart and the last unit of stock the same failure policy.
- Quoting a 99.9% SLO as if it were the availability in the theorem.
- Designing only for the partition and discovering on a healthy Tuesday that every write waits 60 ms.
- Granting a lock, or confirming inventory, from both sides because “the user is waiting.”
- Calling a system CP because it has a primary, while reads are served from an asynchronous replica that lags.
In the interview
Spend the first five minutes naming two operations and one number. “The cart write succeeds on the local side. The inventory reservation needs a majority, so the side that cannot reach a second replica fails the reservation. Healthy, that reservation costs one cross-region round trip, about 40 ms of fiber before routers, and I am assuming 60 ms.” That is a path, a bottleneck, and a tradeoff.
Skip the proof, skip a history of the 2000s blog posts, and skip a taxonomy of every database product. You are not being graded on the triangle.
The question that usually follows is what the shopper sees, and what happens when the partition heals. Have the sentence ready: the cart still holds the line, the lamp may be gone, and the retry reads the majority.
Check yourself
What did Gilbert and Lynch actually prove, and in what model?
In the asynchronous model, during a partition, a system cannot give every non-crashed node a response and also keep linearizability. Asynchronous means a delayed message and a dead node are not distinguishable by waiting. The claim is about that moment, not about a permanent menu of three features.
Why is the pick-two slogan a sloppy summary of that result?
Partition tolerance is not optional on a real network, so you do not get to choose the corner that assumes partitions never happen. The real choice is what a live node does once the partition is already in progress. The C in the proof is linearizability, which is narrower than the word consistency in casual use, and many systems only face the tradeoff while the partition lasts.
In the east-west checkout partition, which operation succeeds in east and which fails?
The cart write succeeds locally. You assumed the cart does not wait for the other region, which is the always-writable choice. The inventory reservation fails in east because east can reach only one of three replicas and a commit needs two. West can still commit if it can reach the witness. After the heal, the east shopper may find the lamp already sold.
What does PACELC ask you to trade when the network is healthy?
Latency against consistency. Waiting for a remote replica buys a stronger answer and spends a round trip, about 40 ms of fiber floor across 4,000 km before routers. Answering locally returns in about 0.5 ms inside a datacenter and can be stale. That trade is present on ordinary traffic, which is why designing only for the partition misses most of the requests.
A teammate says CAP availability means the service meets a 99.9 percent SLO. What did they mix up?
The theorem’s availability means a request to a non-crashed node gets a response during a partition. A 99.9% SLO is a target for a measured fraction of requests over a window, and it allows failures. You can miss the SLO while being “available” in the theorem’s sense on one request, and you can hit the SLO while refusing the minority side of a partition on purpose. Say which one you mean.
Based on: Eric Brewer, CAP; Gilbert and Lynch; Daniel Abadi, PACELC; Amazon Dynamo, SOSP 2007, DeCandia and others; Designing Data-Intensive Applications, Kleppmann and Riccomini.