Consensus algorithms
In distributed software, [nodes] need to work together to maintain a consistent state. However, due to the inherent challenges of distributed software systems – such as network latency, node [failures], and [asynchrony] – it is difficult to achieve [consensus] on the state of the system.
Consensus algorithms address these challenges by ensuring that all participating nodes agree on some state or sequence of events, even when some nodes might fail or act maliciously.
Consensus is the foundation for several distributed coordination patterns, including distributed locking that must guarantee correctness.
Popular consensus algorithms
- Paxos: Paxos works by electing a leader that proposes a value, which is then accepted by a majority of the nodes.
- Raft: Raft works by designating one node as the leader to manage log replication, and ensure consistency across the cluster. The leader stays in authority by sending heartbeats to followers; a follower that stops receiving them starts a new election.
Consensus is especially demanding in peer-to-peer (P2P) networks, where there is no central authority to arbitrate and any peer may join or leave at will.