Skip to main content
PreparationZone Logo
PrepZone

Paxos and ZAB — Conceptual Overview

The classics behind modern consensus — enough depth to read ZooKeeper and Kafka KRaft docs.

Pass checkpoint below

Why this matters

  • Legacy systems and vendor docs still reference Paxos and ZAB — you will operate them even if you implement Raft elsewhere.
  • Architect interviews may compare consensus algorithms and ask when ZooKeeper vs etcd fits.
  • You do not implement Paxos from scratch — you understand guarantees and failure modes of systems that use it.
  • ShardPay uses ZooKeeper for legacy fraud-rule coordination while migrating critical paths to etcd/Raft.
Phase 1: PrepareProposer asks acceptors
Phase 2: AcceptQuorum accepts value
LearnValue chosen
Proposers compete; acceptors vote; learners apply chosen value once a quorum agrees.

Conceptual comparison

Paxos proves that distributed processes can agree on a single value despite failures — via propose, prepare, and accept phases. Multi-Paxos elects a stable leader to run continuous Paxos instances as a log. ZAB (ZooKeeper Atomic Broadcast) orders state updates for ZooKeeper's replicated tree — optimized for primary-backup with crash recovery. Raft repackages similar safety ideas with explicit leader election and log matching rules designed for implementability.

ShardPay engineers reading ZK docs encounter zxid (ZAB transaction id) and ephemeral sequential nodes — this article maps those terms to concepts you already know from Raft.

Algorithm families

  • Paxos (single decree) — Agree on one value in one round. Rarely used alone in production — building blocks for Multi-Paxos. ShardPay's early prototype used a Paxos library for lock service before migrating to etcd.
  • Multi-Paxos — Sequence of slots, each decided by Paxos; stable leader optimizes by skipping prepare phase. Conceptually similar to Raft log replication — leader proposes, majority accepts, learners apply.
  • ZAB — ZooKeeper's protocol: primary order broadcasts, followers ack, quorum sync before commit. ShardPay's fraud-rule engine watches /rules/merchant-99/limit znodes — updates propagate in ZAB order to all ZK followers.
  • Raft — Explicit terms, vote grants, log consistency check on election. ShardPay chose Raft (via etcd) for new services because on-call engineers can trace leader elections in structured logs.
  • Safety vs liveness — All guarantee safety (no two decisions conflict) given majority survival; liveness requires eventual leader election. ShardPay monitors ZK ruok and etcd health — loss of quorum blocks writes (CP) on both.

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 2 sections

  • ZooKeeper and ZAB in ShardPay
  • When to use which system

Test yourself

Answer these before moving on — recall is what makes it stick.