Consensus Algorithms

1. Purpose

Ensure agreement among computers (nodes) in a distributed system.

2. Key Goals:

  • Agreement: All nodes decide on the same value.
  • Termination: Decision-making process ends.
  • Validity: Decided value was proposed by at least one node.

3. Types

  • Leader-Based: One node leads decision-making (e.g., Raft, Paxos).
    • Pro: Strong consistency
    • Con: Less available if leader fails
  • Quorum-Based: Majority agreement required (e.g., Paxos variants).
    • Pro: Good availability
    • Con: Weaker consistency in network splits
  • Proof-of-Work/Stake: Used in blockchains for transaction validation.
    • Pro: Secure, decentralized
    • Con: High energy consumption (PoW), potential centralization (PoS)

4. Use Cases:

5. Choosing

Depends on your system's needs for consistency, availability, fault tolerance, performance, and scalability.

see CAP theorem

Tags::cs: