ZooKeeper
Apache ZooKeeper (Distributed Coordination)
Apache ZooKeeper is a centralized, highly reliable CP (Consistency/Partition-Tolerance) coordination service for distributed systems.
1. Core Architecture & Znodes
ZooKeeper represents cluster configurations in a tree-like hierarchy of data registers called znodes:
/ (Root)
/ \
/services (Persistent) /locks (Persistent)
/ /
/svc-1 (Ephemeral) /lock-0001 (Ephemeral-Sequential)Znode Classifications
1. Persistent: Znodes that persist even after the creator client disconnects. Used for configuration states.
2. Ephemeral: Deleted automatically once the client session closes. Used for node heartbeats.
3. Sequential: ZooKeeper appends an auto-incrementing numeric suffix. Used for distributed locks and leader elections.
2. Consensus Protocol (ZAB)
ZooKeeper uses the ZooKeeper Atomic Broadcast (ZAB) protocol. ZAB runs in two primary phases:
- Recovery (Leader Election): If the leader crashes, nodes run a vote to elect the node with the highest transactional epoch ID.
- Broadcast: The leader proposes updates, waits for a majority write acknowledgment (quorum), and commits.
3. References & Tech Blogs
Related Topics
Expand your knowledge by learning about adjacent concepts in system design.
Event-Driven Scaling with Apache Kafka
Deep-dive into partition offsets, producer acknowledgments, and consumer groups.
Networking Essentials
Learn the important parts of networking that you'll need to know for your system design interviews
API Design
Learn about API design for system design interviews
Cheat Sheet Utility
View and print a concise system design reference card.