Fundamentals 12 min read

Understanding CAP Theorem, Paxos, and ZAB: Balancing Consistency and Availability

This article explains the CAP theorem, its implications for distributed systems, details the Paxos consensus algorithm and its availability optimizations, and introduces ZooKeeper's ZAB protocol, showing how they together address consistency‑availability trade‑offs in real‑world deployments.

Alibaba Cloud Developer
Alibaba Cloud Developer
Alibaba Cloud Developer
Understanding CAP Theorem, Paxos, and ZAB: Balancing Consistency and Availability

CAP Theory Overview

CAP theory, proposed by Eric Brewer, states that a distributed system can simultaneously satisfy at most two of three properties: Consistency (all nodes see the same latest data), Availability (every request receives a response), and Partition Tolerance (the system continues operating despite network partitions).

In large‑scale environments, network partitions are inevitable, forcing designers to choose between consistency and availability for each type of data.

CAP theory diagram
CAP theory diagram

Paxos Consensus Algorithm

Paxos, introduced by Leslie Lamport, guarantees strong consistency by requiring a majority (f+1 of 2f+1) of nodes to agree on a proposal. It achieves high availability by allowing the system to remain operational as long as enough nodes are up, dramatically increasing overall reliability.

The algorithm proceeds in two phases: Phase 1 (prepare) where a proposer obtains the highest numbered accepted proposal from a majority, and Phase 2 (accept) where it proposes a value based on that information. If a majority accepts, the value is chosen.

Paxos protocol diagram
Paxos protocol diagram

ZooKeeper's ZAB Protocol

ZAB (ZooKeeper Atomic Broadcast) builds on Paxos by electing a single leader to serialize proposals, eliminating the need for the prepare phase and avoiding livelocks caused by multiple proposers. The leader ensures total order of updates, while followers act as acceptors.

When the leader fails, a new leader is elected using a Paxos‑style proposal, preserving consistency.

ZAB protocol workflow
ZAB protocol workflow

Key Takeaways

CAP theory highlights the unavoidable trade‑off between consistency and availability under network partitions. Paxos provides a simple yet powerful way to achieve strong consistency while maximizing availability, and ZAB adapts Paxos for practical use in systems like ZooKeeper, offering ordered updates and leader‑based optimization.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CAP theoremConsistencyAvailabilityPaxosZAB
Alibaba Cloud Developer
Written by

Alibaba Cloud Developer

Alibaba's official tech channel, featuring all of its technology innovations.

0 followers
Reader feedback

How this landed with the community

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.