Lesson 2 of 9 · 26m
CAP and PACELC Without the Conference-Slide Nonsense
Use CAP correctly during partitions and PACELC everywhere else, with concrete examples from PostgreSQL, etcd, Cassandra, DNS, and object storage.
CAP is usually taught as if systems choose two letters from a vending machine. Real systems are not CA, AP, or CP as a personality type. They make a choice during a network partition: continue serving possibly divergent state, or refuse work until consistency can be guaranteed. Then PACELC reminds us that the rest of the latency-versus-consistency tradeoff exists even when the network is healthy.
CAP is about partitions
A network partition means some nodes cannot communicate with others. Clients outside the partition may still see both sides. The system then chooses:
Consistency (C): refuse or delay operations that cannot be made consistent
Availability (A): accept operations, accepting divergence or stalenessYou do not get to choose P. Partitions are not a feature toggle. They happen because networks lose packets, links congest, cloud availability zones isolate, or a fleet is accidentally firewalled in half.
CP behavior: preserve correctness by refusing uncertainty
Consensus-backed systems such as etcd and ZooKeeper usually prefer correctness. If a node loses quorum, it stops accepting writes:
etcdctl put /services/api/leader node-7
# Error: etcdserver: request timed outThat timeout is not the system being fragile; it is the system refusing to lie. A controller using etcd for leader election would rather stall than permit two primaries to mutate the same cluster state.
PostgreSQL synchronous replication can make a similar choice. With synchronous_commit = remote_apply, a primary may wait for a synchronous standby. If the standby is unreachable and no replacement is available, writes can block to preserve the promised durability boundary.
AP behavior: keep serving and reconcile later
Dynamo-style systems such as Cassandra often accept writes on whichever replicas can be reached. Conflicting writes may exist at once:
UPDATE carts SET items = items + {'sku-991'} WHERE user_id = 42;If two coordinators accept updates during a partition, later reads must reconcile versions. Cassandra commonly uses timestamps and tunable consistency; application design still matters because "last write wins" can discard meaningful user intent.
DNS is the most familiar availability-favoring system. Resolvers cache records because repeated perfect freshness would be slow, fragile, and unnecessary for most operations. A stale DNS answer is often acceptable; a stale bank balance usually is not.
PACELC: the normal-case tradeoff
PACELC says: if Partition, choose Availability or Consistency; Else, choose Latency or Consistency. Even without a failure, strongly consistent reads often require coordination:
read local replica fast, possibly stale
read quorum slower, fresher
leader-only read simplest ordering, more leader load
linearizable read strongest semantics, highest coordination costAmazon S3 is a useful modern example because it provides strong read-after-write consistency for object operations, but the metadata and storage design still have different costs from a strongly consistent relational row. Object storage semantics are not SQL semantics even when both say "consistent."
Choosing correctly is a business decision
Ask what happens when data is wrong. For a shopping cart, an occasional stale item count may be acceptable. For inventory reservation, double-selling one physical unit may be worse than rejecting a checkout. For metrics, losing or duplicating a few samples is usually tolerable. For security group state, correctness may be worth write unavailability.
Field notes
- CAP does not say a system must be available under all failures; it constrains behavior during partitions.
- "Eventually consistent" is not an excuse for losing user intent; define conflict behavior.
- A synchronous write can still be slow, unavailable, or misconfigured; read the actual durability contract.
- Strong consistency at the storage layer does not automatically make a multi-service workflow atomic.
- Latency is part of correctness in user-facing systems. A correct answer after the user retried may create worse behavior.
Was this lesson helpful?