16. Consistency and CAP
16.2 What is strong consistency?
At the bank: However many counters there are, the bank behaves as if there's one ledger. The moment a withdrawal is confirmed at counter 1, counter 2 can't show the old balance. Ever.
In the system: Strong consistency, in its strictest common form called linearizability, means the system behaves as if there were a single copy of the data:
- once a write is confirmed, every later read, from any replica, returns that value (or a newer one);
- all clients see operations in one agreed order that matches real time.
Figure: strong means one copy as far as anyone can tell; eventual means copies agree once writes stop.
How systems provide it: route reads and writes through a single leader (and don't read from lagging followers), or use consensus (Raft, Paxos; Chapter 14, section 14.8) so a majority agrees before a write is confirmed.
What it costs:
- Latency: replicas must coordinate, often across a network round trip, before answering (16.8).
- Availability during failures: if a replica can't reach the others, it must refuse rather than risk a stale answer (16.6).
Use it where a wrong answer is worse than a slow one: money, stock at checkout, seat bookings, unique usernames, leader election.
Memory code: "Many counters, one ledger."