SystemKit

Consensus, CAP, and Ordering

How machines agree when clocks drift and networks fail. Covers what linearizability means, CAP stated honestly, logical clocks, leader election with fencing tokens, and when to use a coordination service rather than build your own.

Lessons

  1. 01Make replicas look like one copyLinearizability makes a replicated store behave like a single copy, so reads never go back in time, and you pay for it in latency and availability.
  2. 02State CAP honestlyCAP describes one narrow choice: when replicas cannot talk, a node must either refuse a request or risk a stale answer.
  3. 03Order events without trusting clocksMachine clocks disagree enough to reverse cause and effect, so systems that need order use counters passed along with messages.
  4. 04Survive a leader that wakes up lateA lease lets one node lead for a limited time, and a fencing token lets storage reject the leader that slept through its expiry.
  5. 05Agree through a majority logRaft-style consensus keeps one agreed log by electing a leader per numbered term and treating an entry as committed once a majority stores it.
  6. 06Pick 2PC, consensus, or a serviceTwo-phase commit needs every participant to agree on one transaction, consensus needs only a majority, and a coordination service spares you from building it.