Free — no signup required

Zab (ZooKeeper Atomic Broadcast)

2 min read

Another Path to Consensus

Zab (ZooKeeper Atomic Broadcast) is the consensus protocol that powers Apache ZooKeeper, a widely used distributed coordination service. ZooKeeper is used by systems like Apache Kafka (for older versions), Hadoop YARN, and HBase to store configuration, perform leader election, and manage distributed locks.

Like Raft, Zab was designed to be a practical, implementable alternative to raw Paxos. It is a leader-based protocol with two phases: leader election and atomic broadcast (log replication). Zab was developed independently of Raft and predates it, but the two algorithms are conceptually very similar.

Key Characteristics of Zab

  • Primary-order durability: Zab guarantees that if a write was acknowledged to a client by a leader, it will be delivered by all future leaders, even if that leader crashed immediately after acknowledging. This is the same safety guarantee Raft provides.
  • Total order: All updates are delivered to all nodes in the exact same order. This is essential for ZooKeeper's use case — clients need to see a consistent, ordered view of all changes.
  • Epoch numbers: Zab uses "epochs" (equivalent to Raft's terms) to distinguish between different leader tenures and prevent stale leaders from causing inconsistency.

Zab vs. Raft in Practice

The primary difference is in their intended use case. Raft is a general-purpose replicated log protocol — you can build any state machine on top of it. Zab is specifically designed for ZooKeeper's hierarchical data model and its specific consistency semantics. If you are building a new system today, Raft is the more common choice due to its broader ecosystem and documentation. If you are working with ZooKeeper, you are working with Zab.

This is one of 18 chapters

Every chapter is free — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

Sign up free