Fundamentals 7 min read

An Overview of Paxos, Raft, ZAB, and Gossip Algorithms for Distributed Consistency

This article explains the principles, roles, phases, and typical application scenarios of four major distributed consensus algorithms—Paxos, Raft, ZAB, and Gossip—while also offering promotional material for extensive architecture and interview resources.

Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
An Overview of Paxos, Raft, ZAB, and Gossip Algorithms for Distributed Consistency

Distributed algorithms are essential for guaranteeing consistency in distributed systems, and this article provides a detailed overview of four mainstream consensus protocols.

Paxos Algorithm

Paxos is a protocol for achieving distributed consistency, ensuring that multiple nodes agree on a shared state.

It defines three roles: proposer, acceptor, and learner.

The algorithm consists of three phases:

Prepare Phase : The proposer sends a numbered prepare request to a majority of acceptors, asking for the highest-numbered proposal they have accepted.

Proposal Phase : If a majority respond, the proposer sends a proposal with the same number.

Learn Phase : Once a proposal is accepted by a majority, learners can learn the chosen value.

Application scenarios : distributed databases, distributed locks, consistent hashing, and other systems that require strong consistency.

Raft Algorithm

Raft is a more understandable alternative to Paxos that provides the same consistency guarantees.

It involves three roles:

Leader : Handles client requests and replicates log entries to followers.

Follower : Receives and copies the leader’s log entries.

Candidate : Starts an election when it does not hear from a leader, seeking votes to become the new leader.

The core idea is periodic leader election; the elected leader processes client requests and ensures log consistency across followers.

Application scenarios : distributed databases, distributed file systems, and any system that needs consistent log replication.

ZAB Algorithm

ZAB (ZooKeeper Atomic Broadcast) is the consistency protocol used by Apache ZooKeeper.

It operates in two phases:

Leader election: nodes vote to select a leader that will handle client requests.

Broadcast: the leader broadcasts client requests to all nodes and waits for acknowledgments from a majority.

Application scenarios : building coordination services such as Apache ZooKeeper.

Gossip Algorithm

Gossip is a communication algorithm for disseminating information and synchronizing state across nodes in a distributed system.

Each node periodically contacts random peers, exchanging its state so that updates spread quickly, similar to the way a virus propagates.

Application scenarios : distributed storage systems, distributed computation platforms, and any environment that requires efficient information propagation and state synchronization.

At the end of the article, the author offers a free collection of over 300,000 Chinese characters of architecture materials and a comprehensive Java interview question set, inviting readers to add a WeChat contact with the keyword “合集” to receive the resources.

Distributed SystemsRaftPaxosconsensus algorithmsZABgossip
Mike Chen's Internet Architecture
Written by

Mike Chen's Internet Architecture

Over ten years of BAT architecture experience, shared generously!

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.