CAP theorem interview questions, with answers
The CAP theorem is asked in placement interviews because it is short enough to state and deep enough to expose whether a candidate has thought about distributed systems at all. The weak answer is "pick two of three". The strong answer explains why partitions are not optional, what each side actually gives up during one, and what the theorem stays silent about.
These are the questions with those explanations. When you have read them, take the free DBMS diagnostic — ten questions across all fourteen DBMS topics, with the weak ones named.
The questions, with answers
1.What does the CAP theorem state, and what do C, A and P mean?
In a distributed data store, when the network partitions, you cannot guarantee both consistency and availability — you must give up one for the duration of the partition. Consistency here means every read sees the most recent write, as if there were a single copy of the data (linearisability), not the C of ACID. Availability means every request to a working node gets a non-error response, even if it is not the latest data. Partition tolerance means the system keeps operating when messages between nodes are lost or delayed. Eric Brewer conjectured it in 2000; Gilbert and Lynch proved a formal version in 2002. The theorem is about what happens during a partition, which is why the "pick two" phrasing misleads.
2.Why can't a distributed system simply choose to give up partition tolerance?
Because partitions are not a design choice — they are a fact of networks. Cables get cut, switches fail, a node stalls in garbage collection long enough to look dead, a cloud availability zone loses connectivity. A system that spans more than one machine will experience a partition eventually, and it has to do something when it happens: either keep answering on both sides (and risk the sides diverging) or refuse on at least one side (and lose availability). "Giving up P" would mean running on a single node, which is not a distributed system. So the real choice CAP describes is between C and A during a partition, and every distributed database has made it, whether or not its documentation says so.
3.What is the difference between a CP system and an AP system, with examples?
A CP system preserves consistency during a partition by refusing requests it cannot serve consistently: the minority side of the split stops accepting writes (and often reads), so no client ever sees stale or conflicting data. ZooKeeper, etcd, HBase and a traditional relational database with synchronous replication behave this way. An AP system keeps every node answering: both sides accept reads and writes, the data diverges, and the system reconciles the copies once the partition heals — Cassandra, DynamoDB, Riak and CouchDB are the usual examples. The follow-up interviewers like: a bank ledger wants CP, because a wrong balance is worse than a temporary error; a shopping cart or a social feed wants AP, because a stale item is better than a page that will not load.
4.What is eventual consistency?
The guarantee an AP system offers instead of strong consistency: if no new writes arrive, all replicas will converge to the same value eventually. In the meantime a client may read an older value, may see a write it just made disappear when it reads from a different replica, or may see two different answers to the same question from two nodes. What is being relaxed is the promise that a read reflects the latest write. Systems make it more livable with session guarantees — read-your-own-writes, monotonic reads — and with conflict resolution rules such as last-writer-wins, version vectors or CRDTs that merge concurrent updates without losing them. Say what "eventually" costs the user, not just what it means.
5.What does the CAP theorem not say?
It does not say a system is permanently one of C or A — the trade-off applies only while a partition exists, and a well-run cluster spends most of its life without one. It does not say you pick two of three in a design meeting. It does not cover latency, which is the trade-off you actually pay for consistency every day, not just during failures. It does not apply to a single node at all. And it does not use the words consistency and availability the way most people do: CAP-consistency is linearisability, far stronger than "the data makes sense", and CAP-availability is a formal property that a system can fail even while its dashboards say it is up. Interviewers reward candidates who state these limits unprompted.
6.What is PACELC, and why is it considered a better model than CAP?
PACELC extends CAP with the case that CAP ignores: if there is a Partition, choose between Availability and Consistency; Else, when the system is running normally, choose between Latency and Consistency. A replicated system that waits for every replica to acknowledge a write before confirming it is consistent but slow; one that confirms after the local write is fast but may serve stale reads. That trade-off exists every second, not just during failures, so it usually matters more in practice than the P branch. In PACELC terms, DynamoDB and Cassandra are PA/EL, most relational databases with synchronous replication are PC/EC, and MongoDB is PA/EC by default. Giving the four-letter classification of one system you know is a strong answer.
7.What does tunable consistency mean in a system like Cassandra?
The client chooses, per operation, how many replicas must respond before the operation counts as done. With a replication factor of three, a write at consistency level ONE returns after one replica acknowledges; at QUORUM after two; at ALL after three. Reads work the same way. If read replicas plus write replicas exceed the replication factor — QUORUM reads with QUORUM writes, two plus two over three — every read overlaps at least one replica that has the latest write, and you get strong consistency for that data at the price of latency and reduced availability. Drop to ONE on both and you have fast, highly available, eventually consistent operations. So one database can be CP for some operations and AP for others; that is the modern answer to "is Cassandra AP".
8.How is consistency in CAP different from consistency in ACID?
They share a word and little else. ACID consistency is a property of a transaction on a single database: the transaction moves the data from one valid state to another, satisfying every constraint — no negative balances, no orphan foreign keys. CAP consistency is a property of a replicated system: every replica presents the same value for a read, as though there were one copy. A single-node relational database is fully ACID-consistent and CAP does not even apply to it; a replicated Cassandra cluster at consistency level ONE can be CAP-inconsistent while every individual write is perfectly valid. When an interviewer asks which consistency you mean, the fact that you ask back is most of the answer.
How the diagnostic asks it
One question from the DBMS bank, exactly as a sitting would show it. The bank has 4 on cap theorem and 60 across DBMS.
In the CAP theorem, what does the 'P' stand for, and why can a distributed database not simply choose to give it up?
- 1Parallelism — queries must run on several nodes at once
- 2Persistence — data must survive a crash
- 3Partition tolerance — the system keeps operating when the network splits nodes into groups that cannot talk to each other; networks do fail, so partitions must be tolerated, leaving the real choice between consistency and availabilitycorrect
- 4Performance — a system can always trade speed for consistency
A network partition is a loss of communication between nodes; it is a fact of distributed systems, not a design choice, so any system that spans a network must decide how to behave during one. That is why CAP is usually read as 'during a partition, choose consistency or availability'. Performance, persistence and parallelism are real concerns but are not the P in CAP.
Measure it
Reading answers tells you what’s true. A diagnostic tells you what you get wrong.
10 DBMS questions across its topics, easy to hard, about fifteen minutes. You get a readiness figure with the arithmetic shown, the topics you missed named, and a practice set sized for today. Free: 1 diagnostic a month and 15 problems a day. No card.