Explain the CAP theorem and its practical implications.
The CAP theorem, formulated by Eric Brewer, states that a distributed data store can simultaneously provide at most two of three guarantees: Consistency, Availability, and Partition Tolerance.
Consistency means every read receives the most recent write or an error. This is linearizability — not to be confused with ACID consistency.
Availability means every request to a non-failing node receives a response, without guarantee of recency.
Partition Tolerance means the system continues to operate despite network partitions between nodes.
The critical insight: partition tolerance is not optional in distributed systems. Network partitions will happen. So the real choice during a partition is between consistency and availability.
CP systems choose consistency over availability. During a partition, nodes that cannot confirm they have the latest data return errors. Examples: ZooKeeper, etcd, HBase.
AP systems choose availability over consistency. During a partition, all nodes continue serving requests with potentially stale data. Examples: Cassandra, DynamoDB (eventual consistency reads), CouchDB.
A common misconception is that CAP requires you to permanently give up one of the three. The tradeoff only manifests during partitions. When the network is healthy, a well-designed system can provide both. This is why the PACELC extension is more precise: during a Partition, choose A or C; Else, choose between Latency and Consistency.
Another misconception is treating CAP as a system-wide choice. Different subsystems can make different tradeoffs — your auth service might be CP while your product catalog is AP.
Modern databases like CockroachDB and Spanner push boundaries with strong consistency and high availability through consensus protocols, though they still sacrifice availability during severe partitions.
Correctly defines all three properties and states the constraint, but lacks concrete system examples or treats CAP as a permanent binary choice.
Defines all three precisely, clarifies that partitions are inevitable, gives concrete CP and AP examples with rationale, and addresses PACELC or per-subsystem tradeoffs.
Reading the answer is step one. Explaining it unprompted — under interview pressure — is what actually matters. Get AI-graded feedback on your answer with follow-up probes on your weak points.
Get Graded — Free Assessment