Skip to content
— CH. 1 · INTRODUCTION —

Consensus (computer science)

12 min listen · Ch. 1 of 8
8 sections
  • Consensus, in computer science, is the problem of getting a group of computers to agree on a single answer, even when some of them fail. Google's lock service, called Chubby, depends on this problem being solved reliably. It stores lock information in files replicated across machines, running on a fault-tolerant log built on the Paxos algorithm. If even one participating computer crashes, lies, or falls silent at just the wrong moment, an entire system can drift out of agreement. So what actually counts as agreement, when the messengers themselves might be unreliable? What happens when a process does not merely stop working, but actively sends contradictory information to sabotage the outcome? And in a network with no central authority at all, how do total strangers ever manage to agree on anything?

  • A protocol that simply made every process output the binary value 1 would technically finish. But it would be useless, since the result ignores what any process actually proposed. Consensus protocols must instead produce an output that traces back to some process's real input. Once a process decides on that output, the decision can never be revoked.

    Reaching agreement usually starts with a vote, where a majority means at least one more than half of all available votes. One or more faulty processes can skew that count, so the outcome may fail to form or form incorrectly.

    Three formal requirements define a correct consensus protocol: termination, integrity, and agreement. Termination requires that every correct process eventually decides on some value. Integrity states that if every correct process proposed the same value, any correct process that decides must choose that value. Agreement requires that every correct process settles on the same final value. A weaker version of integrity only requires the decided value to match what some correct process proposed, not necessarily all of them. A validity condition appears too, requiring that a message sent by a process must actually be delivered.

    A protocol able to guarantee consensus among n processes, even when as many as t of them fail, is described as t-resilient. Researchers judge these protocols on running time, typically expressed in Big O notation as the number of rounds of message exchange needed. They also weigh message complexity, meaning how much message traffic the protocol generates, along with memory usage and message size.

    None of these properties on their own distinguish between a process that has simply stopped and one that is actively working against the group.

  • A process suffering a crash failure abruptly stops and never resumes activity. A Byzantine failure imposes no such limits at all. It might result from the malicious actions of an adversary, sending contradictory or conflicting data to other processes. A process with a Byzantine failure might also sleep and then resume activity only after a lengthy delay. Of the two, Byzantine failures are far more disruptive to a system trying to reach agreement.

    A stronger version of consensus, built to tolerate Byzantine failures, tightens the Integrity requirement: if a correct process decides on a value, that value must have been proposed by some correct process.

    Guarding against this kind of adversary is part of why some systems require every message to carry proof of who really sent it.

  • In most consensus models, participants communicate through authenticated channels, so receivers always know which process sent a given message. Some models go further with transferable authentication, where every message carries the sender's digital signature. That way, a receiver learns not just who forwarded a message, but who originally created it. Protocols with this stronger authentication can tolerate more faults. The two variants are called oral communication and written communication models. In an oral model, each step only reveals the immediate source. A written model preserves the entire chain of custody as a message passes along.

    Traditional protocols such as Paxos ask cooperating nodes to agree on one single value, like an integer that might encode a database transaction. Binary consensus narrows that further, restricting the output to a single digit, 0 or 1. On its own this is not very useful, but it often serves as a building block inside larger asynchronous protocols. Multi-valued consensus protocols such as Multi-Paxos and Raft instead agree on a whole growing series of values over time. Running a single-valued protocol repeatedly could achieve the same thing, but dedicated multi-valued protocols add optimizations, including support for reconfiguring the group.

    None of these design choices matter much until you ask whether the whole system can even count on messages arriving on time.

  • Real-world networks are inherently asynchronous, but engineers often model consensus protocols as synchronous instead, since asynchronous systems raise far more complications. In a synchronous system, all communication proceeds in fixed rounds. During each round, a process sends every message it needs, then receives all the messages the other processes sent. Nothing from one round can influence the next.

    In 1985, Michael J. Fischer, Nancy Lynch, and Mike Paterson proved that in a fully asynchronous system, no deterministic algorithm can guarantee consensus if even one process might crash. Known as the FLP impossibility result, it was significant enough that the authors were later awarded a Dijkstra Prize. The result has since been mechanically verified to hold even under fairness assumptions. The proof rests on worst-case scheduling scenarios, the kind an intelligent denial-of-service attacker might engineer, rather than situations likely to arise from ordinary randomness in scheduling. FLP does not claim consensus can never be reached. It only shows that no algorithm can always reach it within a bounded amount of time, and in practice that failure is highly unlikely.

    Randomized consensus algorithms sidestep this limit entirely, achieving both safety and correct progress with overwhelming probability, even against the worst-case scheduling the FLP proof relies on.

    That gap between what a system can guarantee and what usually happens in practice matters even more in one particular setting. It's a network with no fixed, trusted list of participants at all.

  • Leslie Lamport's Paxos algorithm, along with variants such as Raft, runs throughout widely deployed distributed and cloud computing systems today. These protocols are typically synchronous, depend on an elected leader to make progress, and tolerate crashes but not Byzantine failures.

    Other protocols, including one called Cerberus, extend Byzantine fault-tolerant consensus to sharded distributed ledgers and have drawn academic analysis in their own right.

    Garay and Berman's Phase King algorithm solves binary consensus in polynomial time, even against Byzantine failures. It works in a synchronous message-passing system with n processes, tolerating up to f failures as long as n is greater than 4f. The algorithm runs through f plus 1 phases, each with two rounds. In the first round of a phase, every process broadcasts its preferred value and tallies which value the majority favored. In the second round, whichever process's ID matches the current phase number becomes that phase's king, broadcasting the majority value it observed to break ties. A process updates its own preference to the majority value only if that value's count exceeded n over 2 plus f. Otherwise, it defers to the king's choice. After all the phases finish, every process outputs its final preferred value.

    Many peer-to-peer online real-time strategy games rely on a modified lockstep protocol to keep game state consistent among players. Every action broadcasts a state change to all other players along with a hash of the total game state, and each player checks the change by applying it locally and comparing hashes. When the hashes disagree, players vote, and whoever ends up in the minority gets disconnected and removed from the game, a moment known as a desync.

    Every one of these systems assumes the circle of participants is already known and trusted. That is true from Paxos's elected leader down to a strategy game's list of players. That assumption breaks down completely once anyone with an internet connection is allowed to show up uninvited.

  • Consensus algorithms traditionally assume a fixed, known set of participants, permissioned in advance through some manual or automatic process so members can authenticate one another. Without that kind of closed, authenticated group, an attacker can mount what is called a Sybil attack. By flooding an open consensus group with enough fake virtual participants, the attacker can overwhelm its fault tolerance threshold and defeat even a Byzantine-resilient algorithm.

    A permissionless protocol flips this model, letting anyone join the network dynamically without asking permission first, while imposing some artificial cost as a barrier against Sybil attacks. Bitcoin introduced the first such protocol, using proof of work paired with a difficulty adjustment function. Participants compete to solve cryptographic hash puzzles, and the probability of solving one is proportional to the computing power a participant commits. Because any node can attempt the puzzle, a Sybil attack is infeasible unless an attacker controls more than half of the network's total computing power. Whoever solves the puzzle first gets to add their proposed block of transactions to the ledger, earning a reward for the effort.

    In 2018, bitcoin mining was estimated to consume non-renewable energy at a rate similar to the entire nations of Czech Republic or Jordan. Ethereum, the largest proof-of-stake network, used just under the energy of 205 average US households by comparison. Partly to avoid that high energy cost, later permissionless protocols adopted alternatives such as proof of stake, proof of space, proof of authority, proof of burn, and proof of elapsed time.

    Ripple takes a different approach, using validating nodes to confirm its ledger through a system called the Ripple Protocol Consensus Algorithm, or RPCA. The process runs in rounds: each server first compiles a list of valid candidate transactions, then gathers candidates from its Unique Nodes List and votes on which are genuine. Transactions clearing a minimum threshold move to the next round, and the final round requires 80 percent agreement before anything is confirmed.

    Unlike proof of work or proof of stake, which reward participants in proportion to what they invest, proof of personhood protocols try to give every real human exactly one unit of voting power regardless of wealth. Proposed ways to achieve that one-per-person distribution include physical pseudonym parties, social network verification, pseudonymized government-issued identities, and biometrics.

    None of these open-network solutions apply in one particular setting. That's when multiple processes read and write to the same block of shared memory instead of passing messages over a network.

  • Solving consensus in a shared-memory system requires concurrent objects: data structures that let multiple processes coordinate by reading and writing shared state. Traditional critical-section implementations risk crashing entirely if a process dies inside the critical section or stalls there for a long time. To address that risk, researchers defined wait-freedom as a guarantee that an algorithm finishes in a finite number of steps.

    Every concurrent object gets a consensus number: the maximum number of processes that can reach consensus using that object in a wait-free way. An object with a given consensus number can implement any object with an equal or lower number, but never one with a higher number. This ranking is known as Herlihy's hierarchy of synchronization objects.

    Ordinary atomic read and write registers sit at the bottom of that hierarchy. They cannot solve consensus even between two processes. Structures like stacks and queues climb a little higher, solving consensus for exactly two processes, but no more. Some objects, though, are universal: they can solve consensus for any number of processes at all, and can simulate any other object through a sequence of operations. That universality is what separates a handful of powerful primitives, like compare-and-swap, from ordinary registers that were never built to referee a crowd.

Common questions

What is consensus in computer science?

Consensus in computer science is the problem of getting multiple processes or agents to agree on a single data value even when some processes are faulty. Applications requiring it include cloud computing, clock synchronization, PageRank, opinion formation, smart power grids, state estimation, control of UAVs, load balancing, and blockchain.

What is the FLP impossibility result for consensus in computer science?

The FLP impossibility result, proved in 1985 by Michael J. Fischer, Nancy Lynch, and Mike Paterson, showed that no deterministic algorithm can guarantee consensus in a fully asynchronous system if even one process may suffer a crash failure. The authors were later awarded a Dijkstra Prize for the work, and it has since been mechanically verified to hold even under fairness assumptions.

What is the difference between crash failures and Byzantine failures in consensus protocols?

A crash failure occurs when a process abruptly stops and never resumes, while a Byzantine failure imposes no such limits and can include sending contradictory data or resuming after a long delay. Byzantine failures are far more disruptive to a consensus protocol than crash failures.

How does Bitcoin achieve permissionless consensus?

Bitcoin achieves permissionless consensus using proof of work paired with a difficulty adjustment function, letting participants compete to solve cryptographic hash puzzles. Whoever solves a puzzle first adds their proposed block of transactions to the ledger and earns a reward proportional to their computational effort, and a Sybil attack is infeasible unless an attacker controls more than half of the network's computing power.

What is the Phase King algorithm used for in consensus?

The Phase King algorithm, developed by Garay and Berman, is a polynomial-time binary consensus protocol that tolerates Byzantine failures. It runs in a synchronous system with n processes and up to f failures, provided n is greater than 4f, working through f plus 1 phases of two rounds each.

What agreement threshold does the Ripple Protocol Consensus Algorithm require?

The Ripple Protocol Consensus Algorithm, or RPCA, requires 80 percent agreement in its final round before transactions are confirmed. Validating nodes compile candidate transactions, vote on them using their Unique Nodes List, and pass transactions clearing a minimum threshold to the next round.

All sources

44 references cited across the entry

  1. 1BookDistributed Systems: Concepts and DesignGeorge Coulouris et al. — Addison-Wesley — 2001
  2. 2JournalAuthenticated algorithms for Byzantine agreementD. Dolev et al. — 1983
  3. 3JournalByzantine Agreement with authenticationLi Gong et al. — 1995
  4. 4BookReplicationM. K. Aguilera — 2010
  5. 6JournalTime- and Space-Efficient Randomized ConsensusJames Aspnes — May 1993
  6. 7BookPrinciples of Distributed SystemsZarko Milosevic — 2009
  7. 8JournalThe Weak Byzantine Generals ProblemL. Lamport — 1983
  8. 10JournalThe Byzantine Generals ProblemL. Lamport et al. — 1982
  9. 11JournalReaching Agreement in the Presence of FaultsLeslie Lamport — April 1980
  10. 12BookDistributed ComputingHagit Attiya — Wiley — 2004
  11. 13Interactive Theorem ProvingBenjamin Bisping et al. — Springer International Publishing — 2016
  12. 14JournalCerberus: The Radix Consensus ProtocolMohammad Jalalzai et al. — 2023
  13. 15JournalCloture Votes: n/4-resilient Distributed Consensus in t + 1 roundsPiotr Berman et al. — 1993
  14. 16The Chubby lock service for loosely-coupled distributed systemsBurrows, M. — USENIX Association Berkeley, CA, USA — 2006
  15. 17Paxos Made Live – An Engineering PerspectiveC. Tushar et al. — ACM Press New York, NY, USA — 2007
  16. 18JournalResilient Asymptotic Consensus in Robust NetworksHeath J. LeBlanc — April 2013
  17. 19JournalConsensus of second-order multi-agent systems in the presence of locally bounded faultsS. M. Dibaji — May 2015
  18. 20JournalResilient consensus of second-order agent networks: Asynchronous update rules with delaysS. M. Dibaji — July 2017
  19. 21Another advantage of free choice (extended abstract): Completely asynchronous agreement protocolsMichael Ben-Or — 1983
  20. 23JournalAn Efficient Algorithm for Byzantine Agreement without AuthenticationDanny Dolev et al. — 1982
  21. 24JournalAn optimal probabilistic protocol for synchronous Byzantine agreementPesech Feldman et al. — 1997
  22. 25BookAdvances in Cryptology - CRYPTO 2006Jonathan Katz et al. — 2006
  23. 26Practical Byzantine Fault ToleranceMiguel Castro et al. — 1999
  24. 27The honey badger of BFT protocolsAndrew Miller et al. — October 2016
  25. 28Efficient Synchronous Byzantine ConsensusIttai Abraham et al. — September 11, 2017
  26. 29Byzantine agreement made trivialSylvio Micali — CSAIL, MIT — March 19, 2018
  27. 30ALGORANDJing Chen et al. — 2016
  28. 31Fast Byzantine Agreement for Permissioned Distributed LedgersThomas Locher — Association for Computing Machinery — 2020
  29. 35The Ripple Protocol Consensus AlgorithmDavid Schwartz et al. — 2014
  30. 37Who Watches the Watchmen? A Review of Subjective Approaches for Sybil-resistance in Proof of Personhood ProtocolsDivya Siddarth et al. — 13 October 2020
  31. 39BookSocial InformaticsGal Shahaf et al. — October 2020
  32. 41UniqueID: Decentralized Proof-of-Unique-HumanMohammad Javad Hajialikhani et al. — 20 June 2018
  33. 42JournalWait-Free SynchronizationMaurice Herlihy — January 1991
  34. 43BookProceedings of the 29th ACM SIGACT-SIGOPS symposium on Principles of distributed computingDamien Imbs et al. — Association for Computing Machinery — 25 July 2010
  35. 44BookProceedings of the twenty-third annual ACM symposium on Principles of distributed computingFaith Fich et al. — Association for Computing Machinery — 25 July 2004