Distributed systems · foundations
Many machines, one system
A distributed system is a collection of independent computers that cooperate over a network and present themselves to users as a single, coherent system. That one sentence hides almost every hard problem in the field: no shared memory, no shared clock, and parts that fail on their own.
Why distribute at all
A single computer is simpler to build, reason about, and debug. We give that up for four reasons:
- Capacity. One machine has a ceiling on CPU, memory, storage, and network bandwidth. Past that ceiling, the only way up is out.
- Availability. One machine is one point of failure. Copies on separate machines let the service survive a crash, a power loss, or a bad disk.
- Locality. Users and data are spread across the planet. Placing computation near them cuts latency that no amount of hardware can remove.
- Sharing. Expensive or unique resources (storage arrays, GPUs, datasets) can be pooled and used by many clients.
The price is coordination. Every decision that used to be a memory read now involves a message over a network that can be slow, lossy, or split. Leslie Lamport famously summed up the downside: you can be stopped cold by the failure of a machine you did not know existed.
Go deepervan Steen & Tanenbaum, Distributed Systems (4th ed., free PDF), ch. 1 · Kleppmann, Cambridge lecture notes
Where the distribution lives
The single-system illusion can be built at different layers of the software stack. Where you put it decides how much the machines must have in common and how much the application has to know.
| Approach | Single system image | Machines must match | Examples |
|---|---|---|---|
| Distributed OS | Strong: processes, files, and memory look local | Yes | Amoeba, Sprite, Plan 9 |
| Network OS | Weak: users log in or mount remote resources | No | Unix hosts with SSH and NFS mounts |
| Middleware | Per service: RPC, queues, storage, scheduling | No | gRPC, Kafka, Kubernetes |
Pure distributed operating systems proved hard to deploy because they demand uniform hardware and full control of every machine. Most systems today reach the same goals through middleware layered on ordinary operating systems. The principles are identical; only the layer changes.
PaperTanenbaum & van Renesse, "Distributed Operating Systems," ACM Computing Surveys 17(4), 1985
Centralized vs. distributed
| Concern | Centralized | Distributed |
|---|---|---|
| State | One memory, one truth | Spread and copied across nodes |
| Time | One clock orders all events | No global clock; order must be inferred |
| Failure | All or nothing | Partial and often ambiguous |
| Communication | Function call, nanoseconds | Network message, micro- to milliseconds |
| Growth | Buy a bigger machine | Add machines |
| Consistency | Free | A design decision with real costs |
Defining traits
Every distributed system shares a handful of properties. Most of the field is about coping with the last three.
- Resource sharing
- Storage, compute, and data on one node are usable from any other.
- Openness
- Components interoperate through published interfaces and protocols, so parts can be replaced or extended.
- Concurrency
- Many processes on many nodes run at once and contend for the same resources.
- No global clock
- Each node has its own clock that drifts. Ordering events requires logical reasoning, not timestamps alone.
- Independent failure
- Any node or link can fail while the rest keep running, and others may not find out.
- Heterogeneity
- Different hardware, operating systems, languages, and administrators must still cooperate.
The absence of a shared clock is subtle enough to deserve its own paper. Lamport showed that "happened before" can be defined purely from message flow, and that logical clocks can order events consistently without synchronized time.
PaperLamport, "Time, Clocks, and the Ordering of Events in a Distributed System," CACM 21(7), 1978
Transparency
Transparency is how much of the distribution a system hides. The goal is that users and programmers can treat many machines as one.
| Type | Hides | Everyday example |
|---|---|---|
| Access | Differences in how local and remote data are reached | A network drive opened like a local folder |
| Location | Where a resource physically sits | A URL or bucket name with no server address |
| Migration | That a resource has moved | A VM live-migrated between hosts |
| Relocation | That a resource moves while in use | A phone call handed off between cell towers |
| Replication | That several copies exist | A file stored three times in cloud storage |
| Concurrency | That others share the resource | Two people editing one shared document |
| Failure | That a component failed and recovered | A request retried on another server |
When hiding hurts
Full transparency is neither possible nor always desirable. Latency cannot be hidden: a call to another continent is a thousand times slower than a local one, and code written as if it were local will crawl. Failure cannot be fully hidden either, because a node that is slow and a node that is dead look the same from outside. Fischer, Lynch, and Paterson proved that with even one possible crash, no deterministic algorithm can guarantee agreement in an asynchronous network.
Good designs expose distribution where it changes behavior (timeouts, partial results, stale reads) and hide it where it does not.
Scalability
A system scales when it handles more load by adding resources, without a matching loss in performance. There are three distinct dimensions:
- Size: more users, requests, and data.
- Geography: nodes and users far apart, where round-trip time dominates.
- Administration: many independent organizations and policies, as on the internet itself.
Scaling out relies on four techniques that recur throughout the field: partitioning (split data or work so each node owns a slice), replication (copy data for read capacity and resilience), caching (keep hot results near the consumer), and asynchrony (avoid waiting on remote replies). At large scale, the slowest few percent of requests start to dominate user experience, so tail latency becomes a design target in its own right.
Fault tolerance
A fault-tolerant system keeps delivering correct service when components fail. The vocabulary is precise: a fault (a flipped bit, a cut cable) may cause an error in state, which may surface as a failure visible to users. Fault tolerance breaks that chain.
How components fail
| Model | Behavior | Difficulty |
|---|---|---|
| Crash | Stops and stays stopped | Easiest to handle |
| Omission | Drops some messages | Needs retries and acknowledgments |
| Timing | Responds, but too late | Indistinguishable from crash under a timeout |
| Byzantine | Arbitrary or malicious output | Needs voting among 3f+1 replicas |
Redundancy comes in three forms: information (checksums, erasure codes), time (retry the operation), and physical (extra hardware or processes). Detecting failure is itself uncertain. A timeout can only suspect a crash, and choosing its length trades fast recovery against false alarms.
PapersChandra & Toueg, "Unreliable Failure Detectors for Reliable Distributed Systems," JACM 43(2), 1996 · Lamport, Shostak & Pease, "The Byzantine Generals Problem," TOPLAS 4(3), 1982
Architectural models
How responsibilities are divided among nodes shapes where bottlenecks and failure points appear.
Client–server is easy to secure and manage but concentrates load and failure on the server. Peer-to-peer removes the center, so capacity grows with every participant, at the cost of harder search, trust, and consistency. Hybrid designs, now the norm, keep a small coordinating service for metadata or membership and push bulk work to the edges. Most large storage and compute systems follow this pattern.
PaperStoica et al., "Chord: A Scalable Peer-to-Peer Lookup Service," SIGCOMM 2001
How nodes talk
Nodes share nothing but the network, so every interaction is a message. Four patterns cover most systems, differing in whether sender and receiver must be active at the same time and whether they know each other.
| Pattern | Coupling | Good for | Start here |
|---|---|---|---|
| RPC | Synchronous, both online | Request–response services | gRPC quick start |
| Message queue | Asynchronous, decoupled in time | Work distribution, buffering spikes | RabbitMQ tutorials |
| Publish–subscribe | Decoupled in time and identity | Event streams, fan-out | Kafka quick start |
| Shared memory | Implicit, via coherence protocol | Parallel computation on clusters | Li & Hudak 1989 |
PapersBirrell & Nelson, "Implementing Remote Procedure Calls," ACM TOCS 2(1), 1984 · Eugster et al., "The Many Faces of Publish/Subscribe," ACM Computing Surveys 35(2), 2003
Eight fallacies
Engineers new to distributed systems tend to make the same false assumptions, catalogued at Sun Microsystems in the 1990s. Each one, believed, produces a specific class of bug.
- The network is reliablePackets drop; code needs retries and idempotent operations.
- Latency is zeroChatty protocols collapse across regions.
- Bandwidth is infiniteLarge payloads saturate links and starve others.
- The network is secureEvery hop needs authentication and encryption.
- Topology doesn't changeHosts move and routes shift; hard-coded addresses break.
- There is one administratorPolicies, versions, and upgrades conflict.
- Transport cost is zeroSerialization and data transfer cost CPU and money.
- The network is homogeneousMixed hardware and protocols need interoperability.
TutorialRotem-Gal-Oz, "Fallacies of Distributed Computing Explained"
The CAP trade-off
Three properties are desirable in any replicated data store:
- Consistency (C): every read sees the most recent write, as if there were one copy.
- Availability (A): every request to a working node gets a response.
- Partition tolerance (P): the system keeps operating when the network splits nodes into groups that cannot talk.
The CAP theorem, conjectured by Brewer and proved by Gilbert and Lynch, says that during a partition you cannot have both C and A. Since real networks do partition, the practical choice is what to give up when they do.
Two refinements matter. First, the choice is not permanent or global; a system can choose differently per operation or per data type. Second, even with no partition, stronger consistency costs latency because replicas must coordinate. The PACELC formulation captures this: under Partition choose A or C, Else choose Latency or Consistency.
PapersGilbert & Lynch, "Brewer's Conjecture and the Feasibility of Consistent, Available, Partition-Tolerant Web Services," SIGACT News 33(2), 2002 · Brewer, "CAP Twelve Years Later," IEEE Computer 45(2), 2012 · Abadi, "Consistency Tradeoffs in Modern Distributed Database System Design," IEEE Computer 45(2), 2012
ExploreJepsen consistency models map
In practice
Three well-documented systems show these trade-offs made on purpose.
Google File System
hybridrelaxed consistency
One master holds metadata; hundreds of chunk servers hold 64 MB chunks, each replicated three times on cheap disks. Failure is treated as normal, not exceptional. Consistency is deliberately relaxed for appends, which suits batch workloads like building a search index. Its open-source descendant is HDFS.
Ghemawat, Gobioff & Leung, SOSP 2003 · Shvachko et al., HDFS, MSST 2010
Amazon Dynamo
peer-to-peerAP
A key-value store where every node is equal. Consistent hashing spreads keys, sloppy quorums keep writes flowing during failures, and version vectors detect conflicting updates for later reconciliation. The shopping cart is the canonical use: losing an "add to cart" costs more than briefly showing a stale cart.
Netflix and chaos engineering
fault tolerancetesting in production
Hundreds of small services run across multiple cloud regions. To make sure redundancy actually works, Netflix injects failures on purpose, killing instances and even whole regions, and measures whether customers notice.
Basiri et al., "Chaos Engineering," IEEE Software 33(3), 2016 · Chaos Monkey
Distributed is not automatically better. If the data fits on one machine and one machine is reliable enough, a single well-tuned host often beats a cluster on speed, cost, and simplicity. McSherry et al. showed single-threaded laptops outperforming published cluster results on several graph workloads.
PaperMcSherry, Isard & Murray, "Scalability! But at what COST?" HotOS 2015
Tools and reading
Try it
- Docker ComposeRun a three-node cluster on one laptop and kill containers to watch failover.
- etcd and ZooKeeperCoordination services that make membership and leader election concrete.
- ns-3 tutorial and OMNeT++Simulate message passing, latency, and link failure.
- The Secret Lives of DataAnimated walkthrough of replication and leader election.
- Jepsen analysesReal databases tested under partitions; shows what CAP looks like in bug reports.
- MIT 6.5840 labsBuild MapReduce and a replicated key-value store in Go.
Read it
- van Steen & Tanenbaum, Distributed Systems, 4th ed.Free textbook; chapter 1 covers everything on this page.
- Kleppmann, Designing Data-Intensive ApplicationsPractitioner view of replication, partitioning, and consistency.
- Tanenbaum & van Renesse, 1985The classic survey of distributed operating systems.
- Lamport, 1978Logical time and event ordering.
- Brewer, 2012What CAP does and does not say.
- DeCandia et al., 2007A complete, production AP design.