What a distributed system is
Why one service is often many computers, and what goes wrong when they have to cooperate over a network. Seven steps, from one server to three that cover for each other.
In 30 seconds
A distributed system is a group of computers that work together over a network and appear to their users as one system.
People build them to handle more load than one machine can, to keep working when a machine fails, and to put data near users around the world.
The price is three new kinds of trouble: messages get lost or delayed, one part can fail while the rest runs, and no two machines agree exactly on the time. Much of the field is about coping with those facts.
What a distributed system is, step by step
Numbers are round and illustrative, and real capacity rarely grows exactly in step with node count. The last step only names the usual tools: replication, consensus and logical clocks are topics of their own.
- Step 1: One computer does it all. A small site can run on a single computer. That is simple, but the machine has a ceiling, here 1,000 requests per second, and it is a single point of failure: if it stops, the whole site stops with it.
- Step 2: Many computers, one system. A distributed system is several computers, called nodes, that cooperate by sending each other messages over a network, and that look like one system from outside. The user sends one request and does not know, or need to know, which node answers.
- Step 3: Why: scale, safety, distance. There are three common reasons to spread a system out. Scale: three nodes serve about three times the load. Reliability: when one node stops, the others keep answering. Geography: a node near the user answers in 20 ms where a distant one takes 150 ms.
- Step 4: The network is unreliable. Nodes can only talk by sending messages, and the network gives no firm promise about any of them. A message usually arrives in a few milliseconds, but it can also be lost on the way, arrive seconds late, arrive twice, or arrive after a message that was sent later.
- Step 5: Partial failure. A single computer tends to fail as a whole. Here, part of the system can fail while the rest keeps running. When A hears nothing from B, it cannot tell whether B crashed, B is slow, or the reply was lost. All A can do is wait for a set time, a timeout, and then guess.
- Step 6: No shared clock. Each node has its own clock, and no two agree exactly. A sets x to 1, then B sets x to 2 a moment later. B’s clock runs 150 ms slow, so B’s write gets the earlier timestamp, and sorting by timestamp makes the older value win. Order across machines has to be worked out some other way.
- Step 7: Built to cope. Distributed systems are designed around these three facts. A request that times out is retried on another node. Data is copied to several nodes so no single one holds the only copy. Decisions are taken by majority, so two nodes out of three can agree and carry on while the third is down or out of date.
Try it yourself
Learn this first
Nothing. This concept starts from scratch.
Learn next
- Consistency models (strong vs eventual)What a read may return after a write when the data lives on three machines. Intermediate
- Database replicationCopies of a database kept in step, and what happens when one falls behind. Intermediate
- Load balancersOne address, many servers: how requests are shared out and dead servers skipped. Beginner
Spotted a mistake on this page?