Search topics and sections

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]

Why a node cannot tell a crashed peer from a slow one Request lost Node B crashed Node B paused Reply delayed Node A(sender) Node A(sender) Node A(sender) Node A(sender) Node B Node B Node B Node B To A, all four look the same: no reply before the timeout timeout timeout timeout timeout busy
Four timing diagrams with time running downward. A request can be lost, Node B can crash, Node B can pause, or the reply can be delayed, and in every case Node A gets no reply before its timeout, so it cannot tell which failure happened.

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]

  1. The network is reliable.
  2. Latency is zero.
  3. Bandwidth is infinite.
  4. The network is secure.
  5. Topology doesn't change.
  6. There is one administrator.
  7. Transport cost is zero.
  8. 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]

Client-server and peer-to-peer networks Client-server Server Client Client Client Client Peer-to-peer request response Peer Peer Peer Peer Peer Peer overlay links
In the client-server model, each client sends requests to one central server and gets responses back. In the peer-to-peer model, equal peers connect directly to some other peers through an overlay network, and no node is central.

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.
Middleware layer in a distributed system Application A Application B Middleware (e.g. RPC, transactions) Local OS 1 Local OS 2 Local OS 3 Hardware Hardware Hardware Computer 1 Computer 2 Computer 3 Network
Middleware sits between the applications and the local operating systems of networked computers. It gives every application one common interface across all machines, so Application A can span Computers 1 and 2.

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.

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 a→ba \to b, is the smallest relation that meets three rules.[2]

  1. If aa and bb are events in the same process and aa comes first, then a→ba \to b.
  2. If aa is the sending of a message and bb is its receipt by another process, then a→ba \to b.
  3. If a→ba \to b and b→cb \to c, then a→ca \to c.

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 C(a)C(a) that respects causal order. Lamport's clock condition is:

a→b  ⟹  C(a)<C(b)a \to b \implies C(a) < C(b)

Here aa and bb are any two events and CC 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]

  1. Each process increases its counter between any two of its own events.
  2. Each message carries the sender's counter value TmT_m, and the receiver sets its counter to at least its present value and greater than TmT_m.

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 TmT_m. These counters are now called Lamport timestamps.

Lamport clocks on a space-time diagram P Q R Time p1 (1) p2 (2) q1 (1) q2 (3) q3 (4) r1 (1) r2 (5) m1, carries 2 m2, carries 4 concurrent (1 vs 4) Each event: add 1. On receive: max(own, carried) + 1
A space-time diagram of Lamport clocks for processes P, Q and R. The orange causal chain from p1 to r2 has increasing timestamps, but r1 at 1 and q3 at 4 are concurrent, so a smaller timestamp does not mean an earlier event.

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 mm traitors this means, for three or more generals, that

n≥3m+1n \ge 3m + 1

where nn 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 generals problem with three generals Commander Lieutenant 1 Lieutenant 2 Commander Lieutenant 1 Lieutenant 2 Scenario 1: Lieutenant 2 is a traitor Scenario 2: Commander is a traitor he said retreat he said retreat traitor Lieutenant 1 sees the same messages in both scenarios With oral messages, 3 generals cannot handle 1 traitor attack attack attack retreat traitor
In the three-generals case of the Byzantine generals problem, Lieutenant 1 gets the same messages whether Lieutenant 2 or the Commander is the traitor, so it cannot tell which one is lying. With oral messages, n=3n = 3 generals cannot tolerate f=1f = 1 traitor.

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 ff servers may crash, the n−fn - f servers left must still be more than half of nn, which gives

n≥2f+1n \ge 2f + 1

where nn is the cluster size. A typical cluster of five servers can therefore tolerate any two failures.[5]

Majority quorum in a five-server consensus clusterClientcommandMajority: 3 of 5S1x=1y=2x=3LeaderreplicateS2x=1y=2x=3FollowerS3x=1y=2x=3FollowerS4failedS5failedn = 5 servers tolerate f = 2 failures (n ≥ 2f + 1)
In a five-server consensus cluster, the leader S1 copies a client command to followers S2 and S3. With S4 and S5 failed, these three servers still form a majority, so n=5n = 5 servers tolerate f=2f = 2 failures because n≥2f+1n \ge 2f + 1.

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.

CAP dilemma during a network partitionDuring a partition, choose consistency or availabilitynetwork partition: messages lostG1G2v1v1v0v0was v0Client AClient Bwrite v1readReply v0 (stale)gives up consistencyWait, no replygives up availability
During a network partition, client A writes v1v_1 to group G1 while group G2 still holds v0v_0. When client B reads from G2, G2 can either reply with stale v0v_0 and give up consistency, or wait without replying and give up availability.

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.

MapReduce dataflow for word count map: input pair → intermediate pairs reduce: merge all values for one key Group by key (shuffle) Split 1 the cat Split 2 the dog Split 3 a cat Map (the,1) (cat,1) Map (the,1) (dog,1) Map (a,1) (cat,1) Reduce (the,2) (a,1) Reduce (cat,2) (dog,1) Output the 2, a 1 Output cat 2, dog 1 Illustrative word count example
MapReduce word count, an illustrative example: each map task emits a (word,1)(word, 1) pair for every word in its split, the shuffle groups pairs by key, and each reduce task adds up the values for its keys.

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

  1. A brief introduction to distributed systems, Maarten van Steen and Andrew S. Tanenbaum, Computing (Springer), 2016.
  2. Time, Clocks, and the Ordering of Events in a Distributed System, Leslie Lamport, Communications of the ACM, 1978.
  3. Distributed Systems lecture notes, Martin Kleppmann, University of Cambridge, 2021.
  4. Email on the definition of a distributed system, Leslie Lamport, 1987.
  5. In Search of an Understandable Consensus Algorithm (Extended Version), Diego Ongaro and John Ousterhout, Stanford University, 2014.
  6. Impossibility of Distributed Consensus with One Faulty Process, Michael J. Fischer, Nancy A. Lynch, and Michael S. Paterson, Journal of the ACM, 1985.
  7. Brewer's conjecture and the feasibility of consistent, available, partition-tolerant web services, Seth Gilbert and Nancy Lynch, ACM SIGACT News, 2002.
  8. The Eight Fallacies of Distributed Computing, Peter Deutsch, nighthacks.com.
  9. Consensus in the Presence of Partial Synchrony, Cynthia Dwork, Nancy Lynch, and Larry Stockmeyer, Journal of the ACM, 1988.
  10. The Writings of Leslie Lamport, Leslie Lamport.
  11. The Byzantine Generals Problem, Leslie Lamport, Robert Shostak, and Marshall Pease, ACM Transactions on Programming Languages and Systems, 1982.
  12. Half a Century of Distributed Byzantine Fault-Tolerant Consensus: Design Principles and Evolutionary Pathways, arXiv, 2024.
  13. Randomized protocols for asynchronous consensus, James Aspnes, arXiv, 2002.
  14. The Part-Time Parliament, Leslie Lamport, Microsoft Research, 1998.
  15. In Search of an Understandable Consensus Algorithm, Diego Ongaro and John Ousterhout, USENIX Annual Technical Conference, 2014.
  16. CAP Twelve Years Later: How the "Rules" Have Changed, Eric Brewer, InfoQ, 2012.
  17. MapReduce: Simplified Data Processing on Large Clusters, Jeffrey Dean and Sanjay Ghemawat, OSDI, 2004.
  18. Apache Hadoop, Apache Software Foundation.
  19. Apache Spark, Apache Software Foundation.
  20. ARPANET, DARPA.
  21. About PODC, ACM Symposium on Principles of Distributed Computing.

Figure

Subtopics

Akka (toolkit)Ali GhodsiAnatoly YakovenkoApache BeamApache FlinkApache GiraphApache ImpalaApache KylinApache SamzaApache SparkApache TezApache ZooKeeperAsynchronous system (distributed computing)At-least-once deliveryAtomic broadcastBarbara LiskovBig dataBlockchainClient–server modelCloud computingCluster managerClustered file systemCoda (file system)Computer clusterConfluentConsensus (blockchain)Consensus (computer science)Consistency modelDaniel LewinDataflow modelDeborah EstrinDesigning Data-Intensive ApplicationsDeterministic rendezvous problemDiego OngaroDistributed algorithmDistributed artificial intelligenceDistributed Computing EnvironmentDistributed data storeDistributed objectDistributed operating systemDistributed tracingDistributed trainingDistributed transactiondistributed.netDoug CuttingEclipse attackEdge computingEmbarrassingly parallelEmin Gün SirerEnd-to-end principleEnterprise application integrationEnterprise Integration PatternsEric Brewer (scientist)Exponential backoffFallacies of distributed computingFencing (computing)Gavin WoodGerhard WeikumGlobal server load balancingGoogle Cloud DataflowGraph processing frameworkGreedy embeddingGrid computingGroup membershipHappened-beforeHole punching (networking)Jay KrepsJeff DeanJepsen (software)Joe BedaJubatusK. Mani ChandyLambda architectureLeslie LamportLoad balancing (computing)Long-running transactionLuiz André BarrosoMatei ZahariaMichael J. FischerMiddlewareMillWheelMulti-agent systemNancy LynchNetwork partitionParallel Virtual MachinePartial synchronyPeer-to-peerPieter HintjensPregel (Google)Presto (SQL query engine)Prime IntellectQuorum (distributed computing)Ray (framework)Ray (software)Recovery-oriented computingRemote procedure callReplication (computing)Sanjay GhemawatScalabilityShared-nothing architectureSpace-based architectureSymposium on Principles of Distributed ComputingSynchronous network modelTopology controlTransactional outboxVitalik ButerinVolunteer computingWatermark (stream processing)Werner VogelsWorld government