Shelves / Distributed Systems
Software Engineering · Volume 5
Distributed Systems
Part V of the Software Engineering roadmap, written out as a textbook that starts from zero. The opening chapter assumes you have only ever run programs on one machine; every later chapter opens with a plain-language Start here section whose experiments were actually run on real clusters (etcd, NATS JetStream, a Kafka-protocol cluster, Redis replicas, PostgreSQL two-phase commit, Toxiproxy faults), then goes all the way down: messaging and Kafka, delivery semantics, consistency models, CAP and PACELC, replication and CRDTs, Raft and Paxos, sagas and the outbox, idempotency, clocks, rate limiting, coordination with fencing, and failure modes. Each chapter ends with a lab of real measurements and a revision sheet, and a final chapter of eight projects turns one backend into a distributed system that survives injected failures.
Two ways to read this book
Every chapter has the same shape: Start here (first principles, plain language, small verified examples) → How deep to go (what each mastery level needs) → full-depth sections → Lab (experiments with real measured output) → Revision sheet (key ideas, numbers to remember, pitfalls, glossary, quiz).
How to use this book
- Read one topic at a time. Each topic heading has a Done tick. Tick it only when you can explain the idea aloud without looking, which is roughly mastery level L2–L3 below.
- Run the code. Every comparison block has tabs for each language; type the example out in at least two of them.
- Take the chapter quiz at the end. A score of 80% or more counts as passed. Wrong answers show the explanation, so re-read that topic and untick it if needed.
- Revisit after a delay. The roadmap's loop applies: recall, explain, implement without notes, break it, measure it.
Mastery levels
Languages used throughout
Kafka examples target Kafka 4.x (KRaft-only; ZooKeeper was removed in 4.0). Where a feature is recent or still maturing (share groups, multi-region consistency options), the text says so. The theory chapters are version-independent.
Contents
- DS·00Start Here: What a Distributed System IsFor readers who have only written programs that run on one machine: what changes when a system spans several, the failures that can't happen on one…6 min
- DS·65Foundations of Distributed SystemsWhy distributed systems are hard, from first principles: partial failure and the impossibility of knowing what happened, network latency and its…21 min
- DS·66Messaging SystemsAsynchronous messaging from first principles: why decouple with a broker, queues versus topics versus logs, producers, consumers, acknowledgements…21 min
- DS·67Kafka in DepthApache Kafka 4.x from the storage layer up: brokers, topics, partitions and segments, replicas, leaders and the ISR, high watermark and acks, KRaft…29 min
- DS·68Delivery SemanticsAt-most-once, at-least-once and "exactly-once" delivery defined precisely: where each comes from (ack and commit ordering), why true exactly-once…17 min
- DS·69Consistency ModelsWhat readers and writers are allowed to observe in a replicated system: linearizability, sequential consistency, causal consistency, PRAM, session…19 min
- DS·70CAP and PACELCThe CAP theorem stated precisely (Brewer's conjecture, Gilbert and Lynch's proof), what C, A and P actually mean, why "pick two of three" is…16 min
- DS·71ReplicationKeeping copies of data on several nodes, in depth: single-leader replication (synchronous, asynchronous, semi-synchronous, chain replication), what…23 min
- DS·72ConsensusGetting nodes to agree despite crashes and unreliable networks: the consensus problem and its properties, its equivalence to total-order broadcast…21 min
- DS·73Distributed TransactionsKeeping data consistent across services and databases: two-phase commit step by step (and why it blocks), three-phase commit, XA and its practical…22 min
- DS·74IdempotencyMaking retries safe: idempotence defined mathematically and practically, naturally idempotent versus non-idempotent operations, HTTP method…18 min
- DS·75Time and OrderingClocks and order in distributed systems: how physical clocks drift, NTP and PTP synchronisation, leap seconds and smearing, wall-clock versus…22 min
- DS·76Rate Limiting and Traffic ControlControlling how much work enters a system: why limit (fairness, protection, cost, abuse), the algorithms (fixed window, sliding log, sliding window…21 min
- DS·77CoordinationThe building blocks for nodes that must cooperate: heartbeats and failure detection (fixed timeouts, phi accrual, SWIM gossip), membership, service…20 min
- DS·78Distributed Failure ModesA field guide to how distributed systems actually fail, with the mechanism, symptoms, detection and defences for each: network partitions (including…21 min
- DS·79Distributed Systems ProjectsEight build-it-yourself projects that turn the tiffin centre's single backend into a small distributed system: an event backbone, an order saga…7 min