Part 08 · Revision sheet
Distributed Systems
Key Terms
- Distributed system — independent computers coordinating only by message over a network, appearing as one system (→ 125)
- Network partition — a break in connectivity splitting reachable nodes into groups that can't reach each other (→ 126)
- Gossip — epidemic, peer-to-peer dissemination of membership and state; no central coordinator (→ 127)
- CAP theorem — during a partition, choose availability or consistency, not both (→ 128)
- PACELC — else (no partition), choose latency or consistency (→ 128)
- Linearizability — every read sees the most recent write, as if there were one copy (→ 129)
- Quorum — minimum number of replicas that must participate for an operation to count as succeeded (→ 130)
- Consensus — getting a set of nodes to agree on one value or log despite failures (→ 132)
- Fencing token — a monotonically increasing number storage uses to reject stale writes from a zombie leader (→ 133)
- Version vector — per-replica counters that positively detect concurrent, conflicting writes (→ 134)
- Lease — a lock that expires on its own after a bounded time, even if the holder never releases it (→ 137)
- Saga — a sequence of local transactions, each with a compensating action, holding no cross-service locks (→ 139)
Decision Rules
- Use heartbeats for small, bounded groups; use gossip for large, dynamic memberships a central checker can't scale to (→ 127)
- Decide CP or AP per data item, not once for a whole system — an account balance and a like count can differ (→ 128)
- Pick the weakest consistency model that still prevents the specific user-visible bug you're protecting against (→ 129)
- Use quorums only in a leaderless design; a single leader already gives linearizable reads/writes more simply (→ 130)
- Use a coordination service's borrowed consensus rather than hand-rolling Raft or Paxos per application (→ 132, → 136)
- Always pair leader election with fencing tokens checked at the protected resource, not just at acquisition (→ 133, → 137)
- Avoid two-phase commit across independently deployed services; use a saga instead (→ 138, → 139)
- Classify any piece of state as partitioned, replicated, or derived, and name its source of truth, before picking a mechanism (→ 140)
- Choose active-passive for disaster recovery; active-active (ideally region-pinned) only when low-latency multi-region writes or residency force it (→ 142)
Numbers & Formulas
- Quorum overlap: W + R > N guarantees overlap ≥ W + R − N; W + R ≤ N gives no guaranteed overlap (→ 130)
- Majority for consensus: a 5-node cluster needs a majority of 3 to elect a leader or commit an entry — same arithmetic as a quorum (→ 132)
- Heartbeat detection delay ≈ interval × missed-beat threshold, e.g. 1 s interval × 3 missed beats ≈ 3 s to suspect failure (→ 127)
Traps
- Treating "suspected down" as confirmed dead and acting on it irreversibly (→ 127)
- Applying one CAP answer to an entire system instead of per data item (→ 128)
- Believing W + R ≤ N is "enough" because it covers most replicas — it gives no overlap guarantee and stale reads appear silently (→ 130)
- Electing a leader without fencing tokens — a zombie leader can still corrupt shared state after being replaced (→ 133)
- Letting a derived copy (cache, index, read model) quietly become the only copy of some fact (→ 140)
Self-Quiz
Mark the questions you can explain and choose which topics to revisit.
Answers are available for this page visit. Browser storage is unavailable.
-
Can you name the four defining properties of a distributed system and one observable symptom of each? (no → revisit 125)
-
Can you state CAP's forced choice during a partition and PACELC's trade-off the rest of the time? (no → revisit 128)
-
Can you compute the guaranteed overlap for a stated N, W, R and say whether it guarantees seeing the latest write? (no → revisit 130)
-
Can you explain why leader election without fencing tokens fails to stop two active leaders? (no → revisit 133)
-
Can you classify a piece of state as partitioned, replicated, or derived and name what keeps it correct? (no → revisit 140)