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?

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.