Distributed Systems

How do I design a system that stays correct, available, understandable and recoverable when computation and data are spread across machines that talk over a network which loses, delays, reorders and duplicates their messages?

Your path through Distributed Systems

0 of 68 Foundation lessons done
0 of 170 lessons done overall
Start: What Actually Makes a System Distributed →

Then follow the stages in order

Each stage builds on the ones before it. Labs and simulators sit right after the lessons they exercise. Open a stage to see its lessons. Full roadmap with goals →

  1. Remote Calls and Partial Failure0 of 18 lessons done
    1. What Actually Makes a System DistributedFoundation≈ 15 min
    2. A Remote Call Is Not a Function CallFoundation≈ 15 min
    3. The Network Changes EverythingFoundation≈ 15 min
    4. No Shared Memory: Every Node Sees a CopyFoundation≈ 15 min
    5. There Is No Global ClockFoundation≈ 15 min
    6. Why Distribute At AllFoundation≈ 15 min
    7. When Not to DistributeFoundation≈ 15 min
    8. Where the Boundary GoesFoundation≈ 15 min
    9. Name the Invariant Before You Choose the ProtocolFoundation≈ 15 min
    10. Partial Failure: The Founding ConditionFoundation≈ 15 min
    11. A Timeout Tells You Nothing About Whether It HappenedFoundation≈ 10 min
    12. Failure Models: What You Are Allowed to AssumeFoundation≈ 15 min
    13. No Heartbeat Does Not Mean DeadFoundation≈ 15 min
    14. Crashed or Just Slow: The Distinction You Cannot MakeFoundation≈ 15 min
    15. Byzantine Failures, and Why You Probably Do Not Assume ThemFoundation≈ 15 min
    16. Fault Domains: What Fails TogetherFoundation≈ 15 min
    17. Correlated Failure: The Independence Assumption Is Usually FalseFoundation≈ 15 min
    18. Redundancy Is Not ResilienceFoundation≈ 15 min
  2. Replication and Consistency0 of 18 lessons done
    1. Why Replicate: What a Second Copy Buys YouFoundation≈ 15 min
    2. Leader-Based Replication: Buying Order With a Single WriterFoundation≈ 15 min
    3. Synchronous Replication: Paying Latency for a Durability GuaranteeFoundation≈ 15 min
    4. Asynchronous Replication: The Loss Window You ChoseFoundation≈ 15 min
    5. Multi-Leader Replication: Accepting Writes in More Than One PlaceFoundation≈ 15 min
    6. Read-After-Write: Letting a User See Their Own ChangeFoundation≈ 15 min
    7. Monotonic Reads: Never Let Time Run BackwardsFoundation≈ 15 min
    8. Quorums: What R + W > N Does and Does Not BuyFoundation≈ 15 min
    9. Leaderless Replication: Every Replica Accepts WritesFoundation≈ 15 min
    10. Consistency Models: What "Consistent" Has To MeanFoundation≈ 15 min
    11. Linearizability: An Operation Is an Interval, Not a PointFoundation≈ 15 min
    12. Serializability vs Linearizability: Two Different PropertiesFoundation≈ 15 min
    13. Eventual Consistency: If Updates Stop, Replicas ConvergeFoundation≈ 15 min
    14. Causal Consistency: Never Show an Effect Before Its CauseFoundation≈ 15 min
    15. Session Guarantees: The Underrated Middle GroundFoundation≈ 15 min
    16. CAP: What the Theorem Actually SaysFoundation≈ 15 min
    17. PACELC: The Trade-off That Exists When Nothing Is BrokenFoundation≈ 15 min
    18. Choosing a Consistency Model: Start From the InvariantFoundation≈ 15 min
  3. Time, Ordering and Conflict0 of 14 lessons done
    1. Two Timestamps Are Not an OrderingFoundation≈ 15 min
    2. Clock Skew: The Gap You Cannot Measure From InsideFoundation≈ 15 min
    3. Never Measure a Duration With the Wall ClockFoundation≈ 15 min
    4. Happens-Before: The Only Ordering You Actually HaveFoundation≈ 20 min
    5. Lamport Clocks: Consistent With Causality, Blind to ConcurrencyFoundation≈ 15 min
    6. Vector Clocks: Buying Concurrency Detection at O(N)Foundation≈ 15 min
    7. Four Orderings, Four PricesFoundation≈ 15 min
    8. Total Order Broadcast Is Consensus Wearing a Different HatFoundation≈ 20 min
    9. Two Writes, No Order, One Answer RequiredFoundation≈ 15 min
    10. Last Write Wins Is Data Loss You Chose by DefaultFoundation≈ 20 min
    11. Version Vectors: Making the Conflict VisibleFoundation≈ 20 min
    12. Only the Application Knows What the Merge MeansFoundation≈ 20 min
    13. CRDTs: Deterministic Merge, Not Correct MergeFoundation≈ 20 min
    14. What "Eventually Converges" Actually RequiresFoundation≈ 20 min
  4. Consensus and Coordination0 of 18 lessons done
    1. What Consensus Actually SolvesFoundation≈ 15 min
    2. Consensus Is Not Magic: The Assumptions It Runs OnFoundation≈ 15 min
    3. Leader Election: Choosing One, and Knowing You Were ChosenFoundation≈ 15 min
    4. Terms and Epochs: Making Stale Leaders HarmlessFoundation≈ 15 min
    5. Split-Brain: Two Nodes, Both Certain They Are In ChargeFoundation≈ 15 min
    6. Fencing Tokens: Making the Stale Actor Safe, Not Just UnlikelyFoundation≈ 15 min
    7. Raft: Elections, Terms and Three StatesFoundation≈ 15 min
    8. The Raft Log: Commit Index, Divergence and ReconciliationFoundation≈ 20 min
    9. Paxos and the Other Protocols: What They Share and Where They DifferFoundation≈ 10 min
    10. Do You Actually Need Consensus?Foundation≈ 15 min
    11. Coordination Couples AvailabilityFoundation≈ 15 min
    12. Coordination Avoidance: Restructuring the Problem Instead of Paying for ItFoundation≈ 15 min
    13. Start From the Invariant, Not From the ArchitectureFoundation≈ 15 min
    14. Distributed Locks: What They Are Actually ForFoundation≈ 15 min
    15. Leases: Authority With an Expiry DateFoundation≈ 15 min
    16. The Stale Lock Holder: A Paused Process Does Not Know It Was PausedFoundation≈ 15 min
    17. Coordination Services: The Primitives, Not the ProductFoundation≈ 15 min
    18. Distributed Uniqueness: One Name, Many ShardsFoundation≈ 15 min
  5. Messaging and Streams0 of 16 lessons done
    1. What a Broker Actually Buys YouIntermediate≈ 15 min
    2. Work Queues: One Task, One Worker, Competing ConsumersIntermediate≈ 15 min
    3. Publish/Subscribe: One Event, Many Independent ReadersIntermediate≈ 15 min
    4. Queue or Pub/Sub: Answer the Question in One SentenceIntermediate≈ 15 min
    5. Acknowledgement: The Two-Line Protocol That Decides Your Delivery SemanticsIntermediate≈ 15 min
    6. Visibility Timeout: The Message Is Hidden, Not YoursIntermediate≈ 20 min
    7. Poison Messages: The One That Fails Every Time, ForeverIntermediate≈ 20 min
    8. A Dead-Letter Queue Is a Workflow, Not a BinIntermediate≈ 20 min
    9. The Log Is Not a QueueIntermediate≈ 20 min
    10. A Topic Is Not One Log: Ordering Lives Inside a PartitionIntermediate≈ 15 min
    11. Consumer Groups: Queue Semantics Inside, Pub/Sub Semantics AcrossIntermediate≈ 15 min
    12. Rebalancing: Everyone Stops So the Partitions Can MoveIntermediate≈ 15 min
    13. Commit Before or After: There Is No Third OptionIntermediate≈ 15 min
    14. Two Clocks: When It Happened and When You Saw ItIntermediate≈ 15 min
    15. Late Events: The Window Already FiredIntermediate≈ 15 min
    16. Watermarks: A Guess About Time, Made Precise Enough to Act OnIntermediate≈ 20 min
  6. Partitioning and Membership0 of 14 lessons done
    1. Why Partition: Four Ceilings, Four Different AnswersIntermediate≈ 15 min
    2. Hash Partitioning and the Modulo TrapIntermediate≈ 15 min
    3. Range Partitioning: Scans You Keep, Hotspots You InheritIntermediate≈ 20 min
    4. The Ring: Keeping the Mapping Stable When Membership ChangesIntermediate≈ 20 min
    5. Virtual Nodes: Many Positions per Machine, and Why It Is Not OptionalIntermediate≈ 20 min
    6. Hot Partitions: The Skew Hashing Cannot FixIntermediate≈ 20 min
    7. Rebalancing: A Load Spike You Schedule for YourselfIntermediate≈ 20 min
    8. Cross-Partition Operations: Paying for What the Split Took AwayIntermediate≈ 20 min
    9. Discovering Services: The Registry Is a Distributed System TooIntermediate≈ 20 min
    10. Cluster Membership: A Belief, Not a FactIntermediate≈ 20 min
    11. Gossip: Epidemic Spread Instead of Everyone Telling EveryoneIntermediate≈ 20 min
    12. Anti-Entropy: Repairing Divergence Nobody ReportedIntermediate≈ 20 min
    13. Merkle Trees: Finding the Difference Without Reading the DataIntermediate≈ 20 min
    14. From Alive-or-Dead to a Suspicion LevelIntermediate≈ 20 min
  7. Workflows and Idempotency0 of 13 lessons done
    1. Atomicity Stops at the Process BoundaryIntermediate≈ 15 min
    2. Two-Phase Commit: Buying Atomicity With a PromiseIntermediate≈ 20 min
    3. The Blocking Window: When 2PC Stops and WaitsIntermediate≈ 20 min
    4. Sagas: Trading Isolation for AvailabilityIntermediate≈ 20 min
    5. A Refund Is Not a RollbackIntermediate≈ 25 min
    6. Orchestration: One Component Owns the WorkflowIntermediate≈ 20 min
    7. Choreography: The Workflow Nobody Wrote DownIntermediate≈ 20 min
    8. The Retry Is a Decision, Not a ReflexIntermediate≈ 20 min
    9. Idempotent Is a Property of the Whole Effect, Not the WriteIntermediate≈ 20 min
    10. What Counts as the Same Operation?Intermediate≈ 25 min
    11. Where You Put the Acknowledgement Decides EverythingIntermediate≈ 20 min
    12. Exactly-Once Is a Scope, Not a GuaranteeIntermediate≈ 20 min
    13. Deduplication: Bounded Memory Against an Unbounded StreamIntermediate≈ 20 min
  8. Overload, Deadlines and Caching0 of 18 lessons done
    1. Backpressure Is a Signal That Has to Travel — and Reach Someone Who Can Slow DownAdvanced≈ 15 min
    2. Rejecting Work on Purpose — and Rejecting It Cheaply Enough to HelpAdvanced≈ 15 min
    3. Decide at the Door Whether the Capacity ExistsAdvanced≈ 15 min
    4. One Retry per Tier Is Not One Retry — It MultipliesAdvanced≈ 15 min
    5. Cap Retries as a Fraction of Traffic, Not as a Count per RequestAdvanced≈ 15 min
    6. Without Jitter, Every Client That Failed Together Retries TogetherAdvanced≈ 15 min
    7. Containment Is Decided by What Is Shared, Not by Where the Service Boundaries AreAdvanced≈ 15 min
    8. Bulkheads: Buying Independence by Giving Up UtilisationAdvanced≈ 15 min
    9. A Deadline Is Divided Across the Call Chain, Not Repeated at Every HopAdvanced≈ 15 min
    10. Pass the Remaining Budget Down, Not a Fresh OneAdvanced≈ 15 min
    11. The Caller Is Gone — Stopping Is Usually Right and Sometimes UnsafeAdvanced≈ 15 min
    12. Send a Second Request After p95 and Take Whichever Answers FirstAdvanced≈ 15 min
    13. Fan Out to 100 and the Component’s Tail Becomes the System’s MedianAdvanced≈ 15 min
    14. A Cache Across Machines Is a Replica With No Replication ProtocolAdvanced≈ 15 min
    15. Invalidation Is a Messaging Problem, Which Is Why Cache Bugs Are HardAdvanced≈ 15 min
    16. One Key Expires and Five Hundred Instances Miss at the Same MillisecondAdvanced≈ 15 min
    17. You Cannot Enumerate the Caches, So TTL Is the Bound and Invalidation Is the OptimisationAdvanced≈ 15 min
    18. Sharding Does Not Help a Single KeyAdvanced≈ 15 min
  9. Storage, Compute and Geography0 of 19 lessons done
    1. A Distributed Database Is a Stack, Not a BoxAdvanced≈ 15 min
    2. Distributed File Systems: Chunks, a Metadata Service, and Where the Copies GoAdvanced≈ 20 min
    3. Object Storage: A Flat Namespace With a Hash Behind ItAdvanced≈ 20 min
    4. Acknowledged, Durable, Replicated: Three Different ThingsAdvanced≈ 20 min
    5. Recovered State Is a Checkpoint Plus the Log After ItAdvanced≈ 15 min
    6. A Consistent Cut, Without Stopping the WorldAdvanced≈ 20 min
    7. Splitting a Computation Across MachinesAdvanced≈ 15 min
    8. MapReduce: The Model That Made the Trade-offs VisibleAdvanced≈ 15 min
    9. The Shuffle Is the JobAdvanced≈ 20 min
    10. Move the Computation to the DataAdvanced≈ 20 min
    11. Who Runs What, and What Happens When a Worker Goes QuietAdvanced≈ 20 min
    12. One Slow Task Sets the Pace for EverythingAdvanced≈ 20 min
    13. A Region Boundary Is a Consistency DecisionAdvanced≈ 15 min
    14. The One Number You Cannot OptimiseAdvanced≈ 20 min
    15. Three Ways to Accept a Write in More Than One PlaceAdvanced≈ 20 min
    16. Active-Passive: Simple to Reason About, Rarely TestedAdvanced≈ 20 min
    17. Active-Active: Every Conflict Scenario Becomes RealAdvanced≈ 20 min
    18. EU and US Are Partitioned. Can Both Keep Accepting Writes?Advanced≈ 20 min
    19. When the Data Is Not Allowed to LeaveAdvanced≈ 20 min
  10. Operating Distributed Systems0 of 22 lessons done
    1. Detect, Contain, Recover, Reconcile, VerifyAdvanced≈ 15 min
    2. Graceful Degradation: Which Dependency Is Actually CriticalAdvanced≈ 15 min
    3. The Steady-State Hypothesis and the Abort ConditionAdvanced≈ 20 min
    4. Cascading Failure: When the Response to Failure Causes More FailureAdvanced≈ 20 min
    5. Dependency Blast Radius: What Dies If This Node DiesAdvanced≈ 15 min
    6. Chaos Engineering Is Not Randomly Breaking ProductionAdvanced≈ 15 min
    7. Fault Injection: The Catalogue, and Which Faults Are HardAdvanced≈ 20 min
    8. Distributed Debugging: The Question LadderAdvanced≈ 15 min
    9. Three Nodes, Three Logs, and You Cannot Sort by TimestampAdvanced≈ 20 min
    10. Microservices Are a Distribution Decision, Not a Scaling TechniqueAdvanced≈ 15 min
    11. The Distributed Monolith: All of the Cost, None of the AutonomyAdvanced≈ 15 min
    12. Four Questions That Test a Proposed BoundaryAdvanced≈ 20 min
    13. The Shared Database: An Honest Trade, Not a ProhibitionAdvanced≈ 20 min
    14. Exactly One Component Owns Each Piece of StateAdvanced≈ 15 min
    15. Source of Truth: The Question Every Inconsistency Incident Is Really AskingAdvanced≈ 15 min
    16. Materialized Views: A Read Model That LagsAdvanced≈ 20 min
    17. Reconciliation Is a Component, Not a Cleanup ScriptAdvanced≈ 20 min
    18. An Agent System Is a Distributed SystemAdvanced≈ 20 min
    19. The Model Retries Because It Cannot See the ResultAdvanced≈ 20 min
    20. Agents Do Not Negotiate. Processes Contend for State.Advanced≈ 20 min
    21. Resuming a Workflow That Died Halfway ThroughAdvanced≈ 20 min
    22. The Failures That Produce No ErrorsAdvanced≈ 25 min

Everything here is a consequence of two sentences

A remote call is not a local function call

A local call returns or throws. A remote call has a third outcome — no answer — and the syntax hides it. Every retry, every idempotency key, every saga and every timeout budget in this domain exists because of that third outcome.

A timeout tells you nothing about whether the work happened

The request may never have arrived, arrived and been dropped, executed and had its reply lost, or still be running. Three of those four mean the work did happen. Code that treats a timeout as a failure is wrong more often than it is right.

The rest of the domain is the work of getting back, in protocol and at a price, the four things a machine boundary takes away: shared memory, one clock, instant communication, and any reliable way to know who is alive.

Start from what you are actually seeing

Nobody arrives asking which consistency model they want. They arrive with a duplicate charge, a queue that will not drain, or two nodes that both think they are the leader. Pick the symptom and the answer is what to think about — never a product to install.

The chain every lesson answers

Two of these fields are required and are what make this a domain rather than a pattern catalogue: the guarantee — the property claimed and its scope — and what a node can actually know, as opposed to what it is inferring.

What guarantee?→What does a node know?→How does it work?→What can fail?→How does it fail?→Where is coordination?→What holds under failure?→How does it recover?→How would you know?→What is the simpler thing?

Tools

Learning modules

170 lessons

What this domain is not

Not a glossary of CAP, Raft, Kafka and microservices, and not a product tour.

Architecture tells you which pattern to pick; Database tells you how replication works; Networking tells you how machines communicate. This domain tells you what the pattern actually guarantees, what the replication cost you in agreement, and what unreliable communication does to correctness. Where a lesson touches a mechanism that another domain owns — a saga, a consistent hash ring, a Kafka partition, an idempotency key — it links that lesson and moves straight on to the reasoning. Nothing here asks you to memorize a product; every lesson asks what guarantee is claimed, what each node can know, what fails, where agreement is unavoidable, and what it costs.

A distributed system is not "many servers"

It is a system whose correctness depends on a component that fails independently and whose state you can only learn about through messages that may be lost, delayed, reordered or duplicated. One app plus one managed database already qualifies. Forty services that share a database and die as a unit are distributed in the worst way and coordinated in none of the good ways.

"Strongly consistent" is not a guarantee

A guarantee names a property and its scope: *linearizable for single-key operations*, *read-your-writes for the session that wrote*, *at-least-once within a partition*. Strip the scope and you have marketing. Every lesson here is required to state one, which is why none of them can end at "it is consistent".

You never detect that a node is down

In an asynchronous network a crashed node and a slow node produce byte-for-byte identical evidence at every observer: silence. You do not detect failure, you decide to treat a node as failed, get agreement on the decision, and fence the old one so being wrong is survivable rather than catastrophic.

This is not concurrency with more latency

Concurrency has shared memory and shared fate: when the process dies, both threads die, and neither is left holding half a decision. Take away shared memory, a common clock, and any reliable oracle for "is the other party alive", and the reasoning changes shape rather than scale.

Nothing is recommended without its cost

Every lesson carries required coordination, failureModes and alternatives fields. A design that cannot name what an operator sees when it breaks, or the simpler thing to try first, is a default being taught rather than a decision being made — and in this domain the price is paid in availability, not only in latency.

Every claim carries how far it generalizes

Simulated clusters, quorum arguments and consensus claims are labelled protocol, assumption, typical or simplified. "R + W > N means you read your write" is true by arithmetic and false under a sloppy quorum; the label is where that difference lives.