03
The choice made visible
Imagine your database runs in two regions, US-East and EU-West. A submarine cable fails — they can't talk. A user writes to US-East. An EU user now tries to read the same key.
CP system (Spanner, Zookeeper, etcd): EU read blocks or errors. You can't confirm the value is latest, so you refuse. Consistency preserved; EU user sees downtime.
AP system (Cassandra, DynamoDB, Riak): EU read returns the old value (or whatever local replica has). Request succeeds. Consistency sacrificed; the two regions now diverge until the network heals, then they reconcile (last-write-wins, vector clocks, etc.).
Neither is universally better. A banking ledger must be CP. A social media feed must be AP. An interviewer asking about CAP wants to see you identify which side your system is on, and why the other side would be wrong.
CP vs AP Under PartitionMermaid
sequenceDiagram
participant U as US User
participant USE as US Region
participant EUW as EU Region
participant E as EU User
Note over USE,EUW: Network partition between regions
U->>USE: write(key=X, val=42)
USE-->>U: OK
rect rgb(255, 240, 240)
Note over EUW: CP system
E->>EUW: read(key=X)
EUW-->>E: ERROR · partition
end
rect rgb(240, 255, 240)
Note over EUW: AP system
E->>EUW: read(key=X)
EUW-->>E: old value · 41
Note over EUW: will reconcile when partition heals
end