SD Core

CAP Theorem

During a network partition, a distributed system must choose consistency or availability — partition tolerance is mandatory.

Interview tip Lead with a 30-second definition, then one real system example and name 2–3 designs where CAP Theorem is non-negotiable.

① What it is (30 seconds)

During a network partition, a distributed system must choose consistency or availability — partition tolerance is mandatory.

② How it works in system design

CP systems (ZK, HBase) reject writes or reads during partition to stay consistent. AP systems (Cassandra, Dynamo) accept writes on both sides and reconcile later.
Typical placement
ClientEdge / GatewayCAPServicesData stores

③ Concrete system design example

Scenario: Social like count (AP): brief wrong count OK, always respond. Bank transfer (CP): block if quorum unavailable to prevent double spend.

④ Important interview Q&A

QuestionAnswer
PACELC?Without partition, trade latency vs consistency — most web apps pick low latency.
Is CAP outdated?Still useful framing; modern systems offer tunable consistency per operation.
Read-your-writes?User sees own updates — route to primary or session version check.

⑤ Seen in these system designs

In interviews, after explaining the concept, say: "This shows up directly in …" and link two designs.

⑥ Revision checklist

  • Define C A P
  • CP vs AP example
  • PACELC mention
  • Problem-specific choice
capconsistencyavailability