Distributed computing
Distributed computing is the part of computer science that studies systems made of many computers that work together over a network. The computers have no shared memory. They coordinate only by sending messages to each other, yet the whole system should look like one machine to its users.[1][2]
The field matters because most large services, from web search to cloud computing, run on many machines at once. It is hard because the parts fail on their own, messages can be slow or lost, and no two machines share an exact clock.[1][3]
What a distributed system is
Definitions
There is no single agreed definition. Maarten van Steen and Andrew Tanenbaum describe a distributed system as "a collection of autonomous computing elements that appears to its users as a single coherent system."[1] They call each computing element a node, which can be a hardware device or a software process.
Leslie Lamport's 1978 definition stresses messages and distance. A distributed system is "a collection of distinct processes which are spatially separated, and which communicate with one another by exchanging messages."[2] He adds a test: a system is distributed if the time to send a message is not small compared with the time between events inside one process.
Lamport also gave a well-known joke definition in a 1987 email to colleagues at Digital Equipment Corporation's research center. "A distributed system is one in which the failure of a computer you didn't even know existed can render your own computer unusable."[4]
Distributed versus parallel computing
Distributed computing overlaps with parallel computing, and the main difference is memory. In a multiprocessor, several CPUs share the same physical memory. In a multicomputer, separate computers are joined by a network and share no main memory, so they must use message passing.[1]
| Multiprocessor (shared memory) | Multicomputer (distributed) | |
|---|---|---|
| Memory | All CPUs reach the same physical memory | Each computer has its own memory |
| How parts communicate | Reading and writing shared memory | Sending messages over a network |
| Ease of programming | Van Steen and Tanenbaum call it "relatively easy to program" | Must handle delays, lost messages, and failures |
The line is not sharp. Lamport notes that even one computer can be viewed as a distributed system whose control unit, memory, and input-output channels are separate processes.[2]
Goals
Van Steen and Tanenbaum name four goals that make a distributed system worth building.[1]
- Resource sharing. Users and programs can reach remote storage, data, files, devices, and services. Sharing one reliable storage system is often cheaper than buying storage for each user.
- Distribution transparency. The system hides where processes and data are, that data may be copied, that others use the same resource, and that parts may fail and recover.
- Openness. Components can be used by, or built into, other systems.
- Scalability. The system keeps working well as it grows in users and resources (size), in distance between parts (geography), and in the number of organizations that run it (administration).
A further goal is fault tolerance. A system built from many machines can avoid having a single point of failure, meaning one part whose loss brings the whole system down. The Internet is designed to have none.[3] Consensus algorithms, for example, let a group of machines keep working as one even when some members fail.[5]
These goals pull against each other. Caching and replication help a system scale, but they create several copies of the same data, and keeping the copies the same is the consistency problem.[1]
Why it is hard
Three problems set distributed systems apart from programs on one computer.
- No global clock. Each node has its own sense of time, so nodes cannot rely on a shared reference to order events.[1]
- Independent failures. One node can crash while the others keep running, and the others may not learn of it.[4]
- An unreliable network. Messages can be delayed, lost, duplicated, or corrupted, and the network can split into parts that cannot reach each other.[6][7]
Telling a slow node from a crashed one
The hardest part of handling failures is telling a crashed node from a slow one.[1] A common failure detector sends a message and marks the other node as crashed if no reply comes back within a timeout. It cannot tell apart a crashed node, a node that is only briefly unresponsive, a lost message, and a delayed one.[3]
Fallacies of distributed computing
Peter Deutsch, then at Sun Microsystems, listed false assumptions that people make when they first build a distributed application.[1] The fallacies of distributed computing in their eight-item form are these.[8]
- The network is reliable.
- Latency is zero.
- Bandwidth is infinite.
- The network is secure.
- Topology doesn't change.
- There is one administrator.
- Transport cost is zero.
- The network is homogeneous.
How systems are organized
Client-server and peer-to-peer
In the client-server model, a server runs a service and clients send it requests, after which the server sends back a response.[1] Many web and database systems work this way.
In a peer-to-peer (P2P) network, the nodes form an overlay network, a logical network of links between nodes that runs on top of the physical one.[1] File-sharing networks such as BitTorrent are examples. In these systems end users, not a central organization, work together to keep the system running.[1]
Middleware
Many distributed systems add a layer of software called middleware that sits on top of each computer's operating system.[1] It gives applications common services so that each one does not have to solve the same problems again.
- Communication, such as the remote procedure call (RPC), which lets a program call a function on a remote computer as if it were local.
- Transactions, which run a group of operations on several services so that either all of them happen or none do.
- Service composition, which joins existing programs, such as web services, into new applications.
Kinds of distributed systems
Van Steen and Tanenbaum sort distributed systems into high-performance computing systems, distributed information systems, and pervasive systems.[1]
| Kind | Main features |
|---|---|
| Cluster computing | Similar computers joined by a fast local network, usually running the same operating system |
| Grid computing | A group of systems from different organizations, with different hardware, software, and security policies |
| Cloud computing | A pool of computing resources, made in software on shared hardware, that customers rent and resize, usually paid per use |
| Distributed information systems | Business applications joined together, often through distributed transactions |
| Pervasive systems | Systems that are naturally distributed, with nodes that can be as small as devices in sensor networks |
System models
A system model states what an algorithm may assume about the nodes, the network, and timing. Martin Kleppmann's Cambridge lecture notes describe the three choices below as "the basis for any distributed algorithm. If your assumptions are wrong, all bets are off!"[3]
Node failures
| Model | What a faulty node does |
|---|---|
| Crash-stop (fail-stop) | Crashes at any moment and never runs again |
| Crash-recovery | Crashes and loses what is in memory, but may resume later; data on disk survives |
| Byzantine (fail-arbitrary) | Departs from the algorithm in any way, including crashing or acting maliciously |
A node that is not faulty is called correct.[3] The name Byzantine comes from the Byzantine generals problem described below.
Network links
The notes model network links as reliable, fair-loss, or arbitrary.[3] An arbitrary link fits the Internet, where the operator of any network along the route can interfere with and alter messages. Encryption protocols such as TLS can almost turn an arbitrary link into a fair-loss one, but they cannot stop an attacker from blocking messages.
Timing
| Model | Timing assumption |
|---|---|
| Synchronous | Every message arrives within a known maximum delay, and nodes run at a predictable speed |
| Partially synchronous | The system behaves synchronously most of the time but may become asynchronous for unknown periods |
| Asynchronous | No timing assumptions; messages may be delayed for any length of time and nodes may run at any speed |
Algorithms built for the synchronous model can fail badly when its bounds are broken, even briefly.[3] Algorithms for the asynchronous model are robust, but some problems cannot be solved there at all.
Cynthia Dwork, Nancy Lynch, and Larry Stockmeyer made partial synchrony precise in 1988.[9] In one version, fixed bounds on message delay and relative processor speed exist but are not known in advance. In another, the bounds are known but hold only from some unknown time on, called the global stabilization time (GST).
Time and the order of events
Because there is no global clock, it is sometimes impossible to say which of two events in a distributed system happened first.[2] Lamport's 1978 paper "Time, Clocks, and the Ordering of Events in a Distributed System" replaced clock time with causal order.
The happened-before relation
The happened-before relation, written , is the smallest relation that meets three rules.[2]
- If and are events in the same process and comes first, then .
- If is the sending of a message and is its receipt by another process, then .
- If and , then .
Two distinct events are concurrent when neither happened before the other. Happened-before is therefore only a partial order: some pairs of events have no defined order.[2]
Logical clocks
A logical clock gives each event a number that respects causal order. Lamport's clock condition is:
Here and are any two events and is the clock value at each event.[2] The reverse does not hold, since a smaller number does not mean an event came first; it may be concurrent.
Lamport gave two rules that meet the clock condition.[2]
- Each process increases its counter between any two of its own events.
- Each message carries the sender's counter value , and the receiver sets its counter to at least its present value and greater than .
One simple way to meet both rules is to add 1 before each event and, on receipt, set the counter to one more than the larger of its own value and . These counters are now called Lamport timestamps.
Lamport later wrote that the paper's main point was often missed. A way to put all events in one total order lets a network of processors carry out any state machine, and so any distributed system.[10] This idea underlies state machine replication.
Agreement and consensus
In the consensus problem, processes each start with a value and the correct ones must agree on one value.[6] Consensus is a building block for keeping copies of data the same, choosing a leader, and committing transactions.
The Byzantine generals problem
Lamport, Robert Shostak, and Marshall Pease framed agreement with faulty parts as a story in 1982.[11] Generals of the Byzantine army surround a city and talk only by messenger. Some generals may be traitors who try to confuse the others, and the loyal generals must still agree on a plan.
With only oral messages, whose contents the sender fully controls, the problem is solvable if and only if more than two-thirds of the generals are loyal.[11] For traitors this means, for three or more generals, that
where is the number of generals. So three generals cannot handle one traitor. With unforgeable signed messages, the problem is solvable for any number of generals and traitors.[11]
Byzantine fault-tolerant consensus is still an active research area, including its use in blockchain systems.[12]
The FLP impossibility result
In 1985 Michael Fischer, Nancy Lynch, and Michael Paterson proved a limit now called the FLP impossibility result.[6] In a fully asynchronous system, every consensus protocol can fail to finish if even one process may crash. This holds even with a reliable network that delivers every message exactly once.
The proof depends on three assumptions.[6]
- No bounds on the relative speeds of processes or on message delay.
- No synchronized clocks, so timeouts cannot be used.
- No way to detect that a process has died, so a dead process looks the same as a very slow one.
The authors stressed that the result does not make consensus impossible in practice. It shows the need for models with more realistic timing or weaker requirements.[6] Later algorithms get around it with randomization, extra timing assumptions, failure detectors, or stronger synchronization tools.[13]
Paxos, Raft, and replicated state machines
In a replicated state machine, several servers keep identical copies of the same state and keep working when some of them are down.[5] A consensus algorithm makes every server's log hold the same commands in the same order. Each server then applies the commands in that order, so the group acts like one highly reliable machine.
Lamport's Paxos algorithm is described in "The Part-Time Parliament." He first submitted it in 1990, and it was published in 1998.[14] Paxos came to dominate the field, and most consensus implementations are based on it or shaped by it, yet many find it hard to understand.[5]
Diego Ongaro and John Ousterhout designed Raft in 2014 with understandability as its main goal.[15] Raft elects one leader, which accepts commands from clients and copies them to the other servers. If the leader fails or is cut off, the servers elect a new one.[5]
Raft stays available as long as a majority of servers work and can talk to each other.[5] If servers may crash, the servers left must still be more than half of , which gives
where is the cluster size. A typical cluster of five servers can therefore tolerate any two failures.[5]
Systems that use consensus include Google's Chubby lock service and Spanner database, both described as based on Paxos, and Apache ZooKeeper, whose algorithm is quite different from Paxos.[5] Viewstamped Replication, by Brian Oki and Barbara Liskov, is a leader-based approach developed around the same time as Paxos.[5]
Replication and the CAP theorem
Copying data to several nodes improves speed and survival, but it raises the question of what readers see when copies differ. A consistency model states the rules. The strongest common one, used in the CAP theorem, requires that all operations appear in one total order, each as if it took effect at a single instant, called atomic consistency or linearizability.[7]
The theorem
Eric Brewer put forward a conjecture at the PODC conference in 2000, and Seth Gilbert and Nancy Lynch proved it in 2002.[16][7] The CAP theorem says a networked shared-data system cannot guarantee all three of these properties at once.[7]
- Consistency (C): reads and writes are atomic, as defined above.
- Availability (A): every request to a node that has not failed gets a response.
- Partition tolerance (P): the system keeps its guarantees even when the network loses any number of messages between nodes, as in a network partition.
Gilbert and Lynch proved the result in the asynchronous model.[7] In partially synchronous models, a practical compromise between consistency and availability is possible.
Later views
Brewer wrote in 2012 that the "2 of 3" summary was always misleading.[16] Partitions are rare, so a system need not give up C or A when there is no partition. The choice can also differ by operation, by data, or by user, and each property comes in degrees rather than all or nothing.
He suggested handling partitions in three steps: detect the partition, enter a partition mode that may limit some operations, and then recover to restore consistency.[16] Systems that favor availability often use weaker models such as eventual consistency.
Frameworks for large-scale data
Frameworks hide many distributed-systems problems from programmers. Jeffrey Dean and Sanjay Ghemawat of Google described MapReduce in 2004.[17] Users write a map function that turns input key/value pairs into intermediate pairs and a reduce function that merges all values sharing a key.
The MapReduce run-time system splits the input, schedules work across many machines, handles machine failures, and manages communication.[17] This let programmers with no experience in distributed systems use a large cluster. A typical job processed many terabytes of data on thousands of machines.
Open-source tools carry these ideas further.
- Apache Hadoop processes large data sets across clusters and includes a distributed file system and a MapReduce engine. It detects and handles failures in software rather than relying on reliable hardware.[18]
- Apache Spark is an engine for data engineering, data science, and machine learning on single machines or clusters.[19]
History
The field grew with computer networks. The first message on the ARPANET was sent between UCLA and the Stanford Research Institute on 29 October 1969, and Lamport's 1978 paper cites the ARPANET as an example of a distributed system.[20][2]
| Year | Event |
|---|---|
| 1969 | First ARPANET message, between UCLA and SRI; the network began with four nodes[20] |
| 1978 | Lamport publishes the happened-before relation and logical clocks[2] |
| 1982 | "The Byzantine Generals Problem" is published; the first Symposium on Principles of Distributed Computing (PODC) meets in Ottawa[11][21] |
| 1985 | The FLP impossibility result appears in the Journal of the ACM[6] |
| 1988 | Dwork, Lynch, and Stockmeyer define partial synchrony[9] |
| 1998 | Paxos is published, eight years after first submission[14] |
| 2000 | Brewer presents the CAP conjecture at PODC[16] |
| 2002 | Gilbert and Lynch prove the CAP theorem[7] |
| 2004 | Dean and Ghemawat describe MapReduce[17] |
| 2014 | Ongaro and Ousterhout publish Raft[15] |
References
- A brief introduction to distributed systems, Maarten van Steen and Andrew S. Tanenbaum, Computing (Springer), 2016.
- Time, Clocks, and the Ordering of Events in a Distributed System, Leslie Lamport, Communications of the ACM, 1978.
- Distributed Systems lecture notes, Martin Kleppmann, University of Cambridge, 2021.
- Email on the definition of a distributed system, Leslie Lamport, 1987.
- In Search of an Understandable Consensus Algorithm (Extended Version), Diego Ongaro and John Ousterhout, Stanford University, 2014.
- Impossibility of Distributed Consensus with One Faulty Process, Michael J. Fischer, Nancy A. Lynch, and Michael S. Paterson, Journal of the ACM, 1985.
- Brewer's conjecture and the feasibility of consistent, available, partition-tolerant web services, Seth Gilbert and Nancy Lynch, ACM SIGACT News, 2002.
- The Eight Fallacies of Distributed Computing, Peter Deutsch, nighthacks.com.
- Consensus in the Presence of Partial Synchrony, Cynthia Dwork, Nancy Lynch, and Larry Stockmeyer, Journal of the ACM, 1988.
- The Writings of Leslie Lamport, Leslie Lamport.
- The Byzantine Generals Problem, Leslie Lamport, Robert Shostak, and Marshall Pease, ACM Transactions on Programming Languages and Systems, 1982.
- Half a Century of Distributed Byzantine Fault-Tolerant Consensus: Design Principles and Evolutionary Pathways, arXiv, 2024.
- Randomized protocols for asynchronous consensus, James Aspnes, arXiv, 2002.
- The Part-Time Parliament, Leslie Lamport, Microsoft Research, 1998.
- In Search of an Understandable Consensus Algorithm, Diego Ongaro and John Ousterhout, USENIX Annual Technical Conference, 2014.
- CAP Twelve Years Later: How the "Rules" Have Changed, Eric Brewer, InfoQ, 2012.
- MapReduce: Simplified Data Processing on Large Clusters, Jeffrey Dean and Sanjay Ghemawat, OSDI, 2004.
- Apache Hadoop, Apache Software Foundation.
- Apache Spark, Apache Software Foundation.
- ARPANET, DARPA.
- About PODC, ACM Symposium on Principles of Distributed Computing.
