Skip to main content
CIS 5020: Critical Analysis of Algorithms
GitHub Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Distributed Algorithms: Consensus and Coordination

Overview

The fundamental challenge of distributed computing: how do multiple machines agree on something when messages can be delayed, reordered, or lost, and machines can crash—or worse, behave maliciously? This module covers the classic problems of leader election, consensus, and Byzantine fault tolerance, including the beautiful impossibility results that define what’s achievable and the clever algorithms that work around them.

The central insight: in a symmetric network where all nodes are identical, you cannot elect a leader. Breaking symmetry requires either unique identifiers or randomization. And in an asynchronous system with even one crash failure, deterministic consensus is impossible (the FLP result). Yet real systems achieve consensus every day—understanding how requires grasping both the impossibility and the workarounds.

Difficulty Level

Intermediate to Advanced

  • Basic leader election (rings, trees): Introductory
  • Consensus with crash failures: Intermediate
  • FLP impossibility result: Intermediate to Advanced
  • Byzantine fault tolerance: Advanced
  • Practical BFT systems (PBFT, blockchain): Advanced

Why This Matters

The infrastructure that runs the world: Every time you use Google, Amazon, or your bank’s website, distributed consensus algorithms are working behind the scenes. When Google’s Spanner database provides globally consistent transactions across continents, it’s using Paxos. When Apache Kafka guarantees message ordering across a cluster, it’s using Zab (a Paxos variant). When your cryptocurrency transaction gets confirmed, it’s through Byzantine consensus.

War Story 1 - The $400 Billion Handoff: The New York Stock Exchange processes over $400 billion in transactions daily. Kenneth Birman’s group communication system (Isis/Isis2) provided fault-tolerant coordination for NYSE’s trading systems. When a server crashes mid-transaction, the remaining servers must agree on the system state—instantly, correctly, without human intervention. One bug in the consensus protocol could mean billions in incorrect trades. The virtual synchrony model that underlies this system came from understanding precisely what guarantees distributed systems can and cannot provide.

War Story 2 - The Byzantine Generals Save Airplanes: The Boeing 777 and 787 flight control systems use Byzantine fault-tolerant algorithms. When a cosmic ray flips a bit in one processor’s memory, causing it to send incorrect data, the other processors must detect and ignore the faulty input. The Byzantine generals problem—solved theoretically in 1982 by Lamport, Shostak, and Pease—is literally keeping aircraft in the sky. The same principles now secure billions of dollars in cryptocurrency.

War Story 3 - Paxos Runs the Internet: Leslie Lamport’s Paxos algorithm (1989/1998) is arguably the most influential distributed algorithm ever designed. Google’s Chubby lock service, which coordinates tasks across Google’s entire infrastructure, is built on Paxos. Apache ZooKeeper (used by Kafka, Hadoop, and countless other systems) implements Zab, a Paxos variant. Amazon’s DynamoDB, Microsoft’s Azure Storage, and virtually every large-scale distributed system uses some form of Paxos or its descendant Raft. Understanding Paxos is understanding how the internet’s backbone actually works.

Core Algorithms

Essential (Leader Election & Basic Consensus)

  1. LeLann-Chang-Roberts (LCR) - Leader election in a ring using unique identifiers, O(n²) messages
  2. Hirschberg-Sinclair - Bidirectional ring election, O(n log n) messages
  3. FloodMax - Leader election in general graphs via flooding
  4. Paxos - The fundamental consensus algorithm for crash failures
  5. Raft - “Understandable” consensus, designed for clarity over Paxos

Intermediate (Consensus Variants & Theory)

  1. Two-Phase Commit (2PC) - Distributed transaction coordination (blocks on coordinator failure)
  2. Three-Phase Commit (3PC) - Non-blocking commit in synchronous systems
  3. Failure Detectors - Abstracting timing assumptions (◇W, ◇S)
  4. FLP Impossibility Proof - Why deterministic async consensus is impossible
  5. Rotating Coordinator - Consensus using synchrony bounds

Advanced (Byzantine Fault Tolerance)

  1. Byzantine Generals Algorithm - Original solution requiring 3f+1 processes for f faults
  2. PBFT (Practical Byzantine Fault Tolerance) - Castro-Liskov’s practical BFT for f Byzantine faults
  3. Tendermint/HotStuff - Modern BFT consensus for blockchain systems
  4. Byzantine Broadcast - Reliable broadcast despite malicious nodes
  5. Randomized Consensus - Using randomization to circumvent FLP

Prerequisites

  • Required:

    • Graph theory basics (rings, trees, general graphs)
    • Understanding of asynchronous vs synchronous systems
    • Basic probability (for randomized algorithms)
    • Proof by contradiction (for impossibility results)
  • Helpful:

    • Operating systems concepts (processes, message passing)
    • Network protocols (TCP, UDP, timing assumptions)
    • State machines (for replicated state machine approach)
    • Cryptographic primitives (for Byzantine protocols)

Problem-Posing Approaches

Story 1: The Symmetric Ring Problem

Setup: Five identical computers sit in a ring network. Each can only communicate with its two neighbors. They need to elect one as the “coordinator” to manage a shared resource.

Initial student intuition: “Easy—just pick the one with the lowest ID!”

The twist: “But they’re identical. No IDs. No distinguishing features. They all run the same code. They all wake up at the same time. How do you break the tie?”

Exploration path:

  • “Could the first one to start be the leader?” → “They all start simultaneously.”
  • “Could they flip coins?” → “Yes! Randomization breaks symmetry. But what if we want a deterministic algorithm?”
  • “Could they pick random IDs?” → “That works—but now they have IDs.”

The fundamental insight: In a symmetric system with deterministic algorithms, leader election is impossible. Any algorithm that works on one node works identically on all nodes. If node A decides it’s the leader, so do B, C, D, and E.

The resolution: Either (1) break symmetry with unique identifiers (the LCR/Hirschberg-Sinclair approach), or (2) use randomization. There is no third option.

Why this matters: This impossibility result shapes all of distributed computing. Real systems assign IDs (IP addresses, UUIDs) precisely because you can’t coordinate without distinguishing nodes.

Story 2: The Unreliable Messenger Problem

Setup: Five generals surround a city. They must all attack at dawn, or all retreat—a partial attack means defeat. They communicate only by messengers, but messengers can be captured (messages lost).

Initial exploration:

  • “General A sends ‘attack at dawn’ to all others.” → “What if the messenger to General E is captured? E attacks alone and loses.”
  • “A sends and waits for acknowledgments.” → “What if A’s messenger reaches E, but E’s acknowledgment is captured? A doesn’t know if E got the message.”
  • “They keep sending until acknowledged.” → “But there’s always a ’last message’ that might be lost. Neither side can ever be certain the other received it.”

The impossibility: The Two Generals Problem proves that with unreliable communication, two parties cannot reach guaranteed agreement on coordinated action. No protocol—no matter how clever—can achieve certainty when messages can be lost.

The pivot to consensus: “So perfect coordination is impossible. But can we get probabilistic guarantees? What if most messages get through?”

This leads to the consensus problem: not requiring guaranteed delivery of every message, but agreement among surviving participants when communication is mostly reliable.

Story 3: The Malicious Processor Problem

Setup: A space probe has three processors voting on navigation decisions. They must agree on the correct course—but one processor might be corrupted by radiation, sending arbitrary (possibly contradictory) data to the other two.

Initial attempts:

  • “Majority vote: if two say ’left’, go left.” → “But the faulty processor might tell Processor A ’the other said left’ while telling Processor B ’the other said right.’”
  • “Share all received values with everyone.” → “The faulty processor lies about what it received too!”

The Byzantine revelation: A processor suffering Byzantine failure can behave arbitrarily—including sending different messages to different recipients, lying about what it received, and coordinating its lies perfectly to confuse honest processors.

Key insight through exploration: “With 3 processors and 1 Byzantine fault, can the 2 honest ones ever agree?”

The theorem emerges: With f Byzantine faults, you need at least 3f + 1 processors to guarantee agreement. With 3 processors and 1 fault, agreement is impossible—the faulty processor can always create a tie.

Why the 3f+1 bound? The faulty processors can simulate each other. With only 3f, the f faulty ones can masquerade as f honest ones, and honest processors can’t distinguish real from fake.

Story 4: The Asynchronous Impossibility

Setup: Three data centers need to agree on whether a transaction commits. Network delays are unpredictable—messages might take milliseconds or minutes. One server might crash silently.

The challenge: “Design an algorithm that always terminates with agreement, even if one server crashes.”

Student attempts:

  • “Wait for all three to respond.” → “If one crashes, you wait forever.”
  • “Decide when two respond.” → “But you can’t tell if the third crashed or is just slow.”
  • “Use a timeout.” → “There’s no ‘correct’ timeout in an asynchronous system. Any timeout either risks deciding before a slow process or waiting forever.”

The FLP bombshell: Fischer, Lynch, and Paterson (1985) proved that in an asynchronous system with even one possible crash failure, no deterministic protocol can guarantee consensus termination. There’s always some execution where the algorithm runs forever.

The practical response: Real systems aren’t purely asynchronous—they have partial synchrony (usually messages arrive quickly, occasional delays are bounded). Protocols like Paxos and Raft work by making progress when the system behaves synchronously, and remaining safe (never deciding incorrectly) even during asynchronous periods.

Cognitive Applications (from Algorithms to Live By)

The coordination overhead of everyday life: Distributed consensus appears constantly in human coordination:

  • “Where should we meet for dinner?” requires agreement despite unreliable communication (missed texts, different preferences)
  • Group projects require consensus on deadlines, division of work, quality standards
  • Organizations must agree on policies despite conflicting interests and incomplete information

When to use timeouts vs. wait forever: The FLP impossibility captures a real tension: wait too short and you might act on incomplete information; wait too long and you never act. Real systems (and people) use adaptive timeouts—wait longer when things seem slow, give up when waiting becomes costly.

Byzantine failures in human systems: Some agents don’t just fail—they actively mislead:

  • Fake news spreads contradictory information to different audiences
  • Bad actors in negotiations say different things to different parties
  • Detecting Byzantine behavior requires cross-checking information across trusted channels

The cost of consensus: Consensus requires communication—O(n²) messages in classic protocols. This is why organizations struggle as they grow: coordinating 10 people is manageable; coordinating 10,000 requires hierarchical structures (essentially running Paxos with designated leaders).

Key Resources

Textbooks

  • Fokkink “Distributed Algorithms” (2018) - Most accessible, intuition-first approach, excellent for problem-posing
  • Lynch “Distributed Algorithms” (1996) - The rigorous theoretical bible, FLP proof, comprehensive impossibility results
  • Attiya & Welch “Distributed Computing” (2004) - Unified treatment across models, good balance of rigor and accessibility
  • Cachin, Guerraoui, Rodrigues “Reliable and Secure Distributed Programming” (2011) - Best Byzantine coverage, layered scaffolding
  • Kleppmann “Designing Data-Intensive Applications” (2017) - Practical context, explains “why” behind designs

Papers (Essential Reading)

  • Lamport, “Paxos Made Simple” (2001) - The definitive plain-English Paxos explanation
  • Ongaro & Ousterhout, “In Search of an Understandable Consensus Algorithm” (2014) - Raft paper, designed for clarity
  • Fischer, Lynch, Paterson, “Impossibility of Distributed Consensus with One Faulty Process” (1985) - The FLP impossibility
  • Lamport, Shostak, Pease, “The Byzantine Generals Problem” (1982) - Original Byzantine formulation
  • Castro & Liskov, “Practical Byzantine Fault Tolerance” (1999) - PBFT, making BFT practical

Courses & Tutorials

  • MIT 6.824 Distributed Systems - Labs implement Raft, excellent paper discussions, free online
  • Raft Visualization (raft.github.io) - Interactive exploration of consensus
  • “Paxos Explained from Scratch” (Meling & Jehl) - Problem-posing derivation showing why naive solutions fail
  • Heidi Howard’s Distributed Consensus Reading List - Curated research papers, regularly updated

Videos

  • Ongaro’s Raft talk (USENIX ATC 2014) - Clear explanation with visualizations
  • Lamport’s Paxos lectures - From the source, with historical context
  • MIT 6.824 lecture videos - Full course online, paper-based discussions

Connections to Other Topics

  • Randomized Algorithms: Randomization breaks symmetry and circumvents FLP impossibility
  • Graph Algorithms: Leader election algorithms depend on graph structure (rings, trees, general)
  • Complexity Theory: Communication complexity lower bounds on consensus
  • Parallel & Distributed Algorithms: Consensus is the coordination primitive for parallel systems
  • Cryptography: Byzantine protocols increasingly use cryptographic signatures
  • Streaming Algorithms: Distributed streaming requires coordination on what to track
  • Online Algorithms: Real-time consensus decisions without complete information

Possible Projects

  1. Implement Raft from Scratch

    • Build a working Raft implementation in Go, Rust, or Python
    • Handle leader election, log replication, and membership changes
    • Test with chaos engineering (network partitions, node failures)
    • Compare performance with academic implementations
    • Outcome: Deep understanding of consensus mechanics; portfolio piece
  2. Visualize the FLP Impossibility

    • Create interactive visualization showing how adversarial scheduler prevents termination
    • Allow users to try different protocols and see them fail
    • Explain each step of the impossibility proof through animation
    • Outcome: Intuition for why asynchronous consensus is hard
  3. Byzantine Fault Simulator

    • Build a simulator where Byzantine nodes can lie strategically
    • Implement simple voting, then show it fail with 1/3 Byzantine nodes
    • Implement PBFT and show it succeeding with same adversary
    • Explore the 3f+1 bound experimentally
    • Outcome: Visceral understanding of Byzantine fault tolerance
  4. Compare Consensus Protocol Performance

    • Benchmark Paxos vs Raft vs Zab under various failure scenarios
    • Measure latency, throughput, recovery time
    • Analyze how leader election timing affects performance
    • Deploy across real distributed infrastructure (AWS, GCP)
    • Outcome: Practical systems experience; publishable results
  5. Build a Byzantine-Tolerant Key-Value Store

    • Implement replicated key-value store tolerating f Byzantine failures
    • Use PBFT or HotStuff as consensus layer
    • Benchmark against crash-only implementations
    • Analyze the performance cost of Byzantine tolerance
    • Outcome: Full-stack distributed systems experience

Estimated Coverage Time

3-5 lectures depending on depth

  • 3 lectures (core): Leader election impossibility + LCR, Paxos/Raft, FLP impossibility overview
  • 4 lectures (+ Byzantine): Add Byzantine generals problem, PBFT overview
  • 5 lectures (comprehensive): Add 2PC/3PC, failure detectors, randomized consensus, blockchain connection

Common Misconceptions

  1. “Paxos and Raft are fundamentally different algorithms”

    • False! Research shows they’re more similar than different. Both use leader-based consensus with similar message patterns. Raft’s clarity comes from presentation and pragmatic choices (e.g., disallowing holes in logs), not fundamentally different mechanisms.
  2. “Byzantine fault tolerance is only for adversarial settings like blockchain”

    • False! Byzantine faults include any arbitrary behavior—cosmic ray bit flips, firmware bugs, misconfigured servers. Aerospace systems use BFT without any malicious actors involved.
  3. “The FLP result means consensus is impossible in practice”

    • False! FLP proves impossibility for deterministic algorithms in purely asynchronous systems. Real systems use partial synchrony (timeouts) and/or randomization to circumvent FLP. Paxos and Raft work perfectly well in practice.
  4. “More replicas always means better fault tolerance”

    • False! With f crash faults, you need 2f+1 replicas. With f Byzantine faults, you need 3f+1. But beyond tolerating the specified failures, more replicas mean more communication overhead and slower consensus.
  5. “Leader election and consensus are the same problem”

    • Related but distinct! Leader election chooses one node. Consensus agrees on a value (which could be “who is leader”). You can solve leader election with consensus, but some leader election algorithms (like LCR) are simpler than full consensus.
  6. “If my system uses Raft, it’s Byzantine fault tolerant”

    • False! Raft (and Paxos) only tolerate crash faults—nodes that stop but don’t lie. A single Byzantine node can completely break Raft by sending contradictory messages.

What Makes This Problem-Posing?

Traditional (banking model):

“Definition: A consensus protocol satisfies Agreement, Validity, and Termination. Here is the Paxos algorithm. Here is the correctness proof. Memorize the three phases. Apply to homework problems.”

Problem-posing approach:

“You have three servers that need to agree on a value. One might crash. Design a protocol. Your first attempt fails because… Let’s try again. This one fails because… What if we add acknowledgments? Still fails because… What minimal assumptions do we need? Ah—we need to know something about timing, or use randomization. Now let’s see how Paxos cleverly solves this…”

The difference: Students experience why consensus is hard before being told the solution. They try naive protocols and watch them fail. They discover the fundamental trade-offs (safety vs. liveness, synchrony vs. asynchrony, crash vs. Byzantine) through exploration. When they finally see Paxos or PBFT, they understand why each mechanism exists—it solves a specific failure mode they’ve already encountered.

The impossibility results (symmetric leader election, two generals, FLP, Byzantine bounds) become explanations rather than obstacles—they explain why certain intuitive approaches don’t work and what assumptions are necessary for solutions.

When to Cover This

Curriculum placement:

  • Week 4-6 for graduate distributed systems courses
  • After basic algorithm analysis and graph algorithms
  • Can come before or after parallel algorithms (complementary perspectives)

Prerequisites check: Students should understand:

  • Graph connectivity and traversal
  • Proof by contradiction
  • Basic probability (for randomized variants)
  • State machine concepts (helpful but can be introduced)

Why mid-semester: Students need algorithmic maturity to appreciate impossibility proofs. Early coverage risks students memorizing results without understanding. But don’t wait too long—consensus is foundational for understanding real distributed systems.

Pedagogical sequence:

  1. Start with leader election in rings (simple, visual, builds intuition)
  2. Introduce symmetry impossibility (mind-blowing but accessible)
  3. Move to consensus via the generals problem (motivating, historical)
  4. Cover Paxos/Raft (practical, connects to real systems)
  5. Introduce FLP (explains why Paxos seems complex)
  6. Advance to Byzantine (for students wanting depth)

Connection to practice: Bring in real systems early—ZooKeeper, etcd, CockroachDB, blockchain. Students should see that these algorithms run critical infrastructure, not just live in textbooks.


Ready for students? ✓ Yes - Starts from fundamental intuition (symmetric rings), builds through classic impossibility results, connects theory to systems used daily (Paxos/Raft in production), provides clear problem-posing entry points, includes both crash and Byzantine fault models with appropriate depth progression.