Apache ZooKeeper
- Problem solved: coordinate the processes of a distributed system (configuration, group membership, leader election, locks) without every project reinventing, bugs included, its own solution.
- Era: code imported from SourceForge into the ASF in June 2008 (Hadoop subproject), USENIX ATC paper in 2010, Apache top-level project on November 17, 2010; Kafka drops it entirely in March 2025.
- Created by: Patrick Hunt and Mahadev Konar (Yahoo! Grid), Flavio Junqueira and Benjamin Reed (Yahoo! Research).
- Category: distributed coordination service.
Historical context
A distributed system always has the same basic needs: share a configuration, know which servers are alive, elect a master, take locks. Each team can code them itself, but the ZooKeeper documentation warns: "Coordination services are notoriously hard to get right", prone to "race conditions and deadlock".
Google answered with Chubby, a lock service that Bigtable depends on, to the point that "If Chubby becomes unavailable for an extended period of time, Bigtable becomes unavailable". At Yahoo!, four researchers and engineers (Patrick Hunt, Mahadev Konar, Flavio Junqueira, Benjamin Reed) took another path: no server-side locks, but a small core on which everyone builds their own primitives. Seen from the API, ZooKeeper looks like "Chubby without the lock methods, open, and close".
The code first lived on SourceForge. On June 6, 2008, Patrick Hunt opened ticket ZOOKEEPER-1, "Initial ZooKeeper code contribution from Yahoo!": an SVN repository dump that made ZooKeeper a Hadoop subproject. At Yahoo!, it served the web crawler's fetching service and Yahoo! Message Broker. The paper "ZooKeeper: Wait-free coordination for Internet-scale systems" was presented at USENIX ATC in 2010, and on November 17, 2010 the ASF made it a top-level project, with Patrick Hunt as Vice President.
ZooKeeper then became the glue of the ecosystem: HBase stores
the location of its hbase:meta table there, HDFS relies on it for automatic
NameNode failover, Facebook built a discovery service on it for Messages
(2010), and Kafka stored its metadata in it. Then the tide
turned: in 2019, the KIP-500 proposal set out to remove ZooKeeper from Kafka,
which got there with version 4.0 in March 2025, paying tribute along the way
to "the backbone of Kafka for more than 10 years".
Key idea
Offer a coordination kernel rather than ready-made primitives. ZooKeeper exposes a small replicated in-memory data tree, and two guarantees: linearizable writes (all ordered by a leader through the Zab protocol) and FIFO ordering of each client's operations. The API is wait-free: no operation blocks, because "Blocking primitives [...] can cause [...] slow or faulty clients to impact negatively the performance of faster clients". Locks, groups and elections become recipes written on the client side.
How it works
- Znodes: the tree is made of nodes (znodes) addressed by a path, holding small data ("in the byte to kilobyte range"). They are "not designed for general data storage".
- Ephemeral and sequential: an ephemeral znode disappears when its creator's session ends (including through a crash); a sequential znode gets an increasing counter appended to its name.
- Watches: a client can ask to be notified of a change. They are one-time triggers that signal that a change happened without describing it.
- Ensemble: several servers replicate the tree. Writes go through a
leader, the others (followers) follow; Zab decides by majority, so with
2f + 1 servers it tolerates f failures (5 servers survive 2 failures). Reads
are served locally by any server, hence fast but possibly stale:
syncforces a catch-up before a read. - Conditional write:
setData(path, data, version)only writes if the version matches, which avoids overwriting a concurrent update.
Lock recipe from the paper: each client creates an ephemeral sequential znode and only watches its predecessor, which avoids waking everyone up on each release ("herd effect"):
1 n = create(l + "/lock-", EPHEMERAL|SEQUENTIAL)
2 C = getChildren(l, false)
3 if n is lowest znode in C, exit
4 p = znode in C ordered just before n
5 if exists(p, true) wait for watch event
6 goto 2
By the numbers
| Figure | Context | Source |
|---|---|---|
| 460,000 operations/s | Pure reads on a saturated 13-server ensemble (2010) | ATC 2010 paper |
| 21,000 versus 8,000 | Pure writes per second with 3 servers, then with 13 (2010) | ATC 2010 paper |
| 10:1 to 100:1 | Read/write ratio of the Yahoo! crawler fetching service (2010) | ATC 2010 paper |
| Version 175 | Revision of the SourceForge SVN repository handed to the ASF (June 2008) | Jira ZOOKEEPER-1 |
| Under 200 ms | Observed time to elect a new leader | ZooKeeper docs |
| 5 people | Apache ZooKeeper project committee at creation (November 2010) | ASF board, 2010 |
| More than 10 years | How long ZooKeeper was the backbone of Kafka (2025) | Kafka 4.0 blog |
Milestones
- June 6, 2008: ZOOKEEPER-1, the code is imported from SourceForge into the ASF as a Hadoop subproject (committed on June 12, target version 3.0.0).
- October 22, 2008: ZooKeeper 3.0.0, first release published at the ASF (date of the ASF archive upload).
- 2010: paper "ZooKeeper: Wait-free coordination for Internet-scale systems" at USENIX ATC.
- November 17, 2010: the ASF board creates the Apache ZooKeeper project, Patrick Hunt Vice President.
- November 16, 2011: ZooKeeper 3.4.0 (date of the ASF archive upload).
- October 30, 2019: umbrella ticket KAFKA-9119 for KIP-500, replacing ZooKeeper in Kafka.
- March 3, 2020: ZooKeeper 3.6.0, with persistent recursive watches.
- October 3, 2022: Kafka 3.3 declares its KRaft mode (without ZooKeeper) production ready.
- March 18, 2025: Kafka 4.0, "the first major release to operate entirely without Apache ZooKeeper".
Did you know?
- The official overview page is titled "ZooKeeper: Because Coordinating Distributed Systems is a Zoo".
- Adding servers raises reads (460,000/s with 13 servers) but lowers writes (from 21,000 to 8,000/s): each write goes through atomic broadcast and must be logged to disk before being acknowledged. Yahoo! partitioned its data across several ensembles to write more.
- The lock recipe uses no "lock" function at all: an ephemeral znode, a sequence number and a watch are enough.
- Kafka also blamed watches for their limited number and for not giving the current state, "only that the state has changed".
Strengths and limitations
| Strengths | Limitations |
|---|---|
| Simple primitives, reusable recipes (locks, groups, election) | One more distributed system to deploy and operate |
| Linearizable writes, FIFO order per client | Slower writes: leader, atomic broadcast and disk log |
| Very fast local reads | Reads possibly stale without sync |
| Failure detection through ephemeral znodes | Small data only, one-time watches |
What came next
- Kafka replaces ZooKeeper with its own Raft quorum of controllers (KRaft): KIP-500 in 2019, production in 3.3 (2022), ZooKeeper removed in 4.0 (2025). The argument: spare administrators "two separate distributed systems".
- HBase and HDFS (NameNode high availability since Hadoop 2.0.0, with the ZKFailoverController process) remain users.
- In the Hadoop ecosystem, ZooKeeper sits next to YARN; its role in YARN high availability remains to be sourced.
Sources
raw-data/apache/zookeeper/zookeeper.md- Hunt, Konar, Junqueira, Reed, "ZooKeeper: Wait-free coordination for Internet-scale systems", USENIX ATC 2010: https://www.usenix.org/legacy/event/atc10/tech/full_papers/Hunt.pdf
- https://zookeeper.apache.org/doc/current/zookeeperOver.html
- Jira ZOOKEEPER-1: https://issues.apache.org/jira/browse/ZOOKEEPER-1
- ASF board, November 17, 2010: https://www.apache.org/foundation/board/minutes/2010/board_minutes_2010_11_17.html
- https://zookeeper.apache.org/releases.html ; https://archive.apache.org/dist/zookeeper/
- https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HDFSHighAvailabilityWithQJM.html
- https://hbase.apache.org/book.html
- Chang et al., Bigtable, OSDI 2006: https://static.googleusercontent.com/media/research.google.com/en//archive/bigtable-osdi06.pdf
- https://engineering.fb.com/2010/11/15/core-infra/the-underlying-technology-of-messages/
- KIP-500: https://cwiki.apache.org/confluence/display/KAFKA/KIP-500%3A+Replace+ZooKeeper+with+a+Self-Managed+Metadata+Quorum ; https://issues.apache.org/jira/browse/KAFKA-9119
- KIP-833: https://cwiki.apache.org/confluence/spaces/KAFKA/pages/211882739/KIP-833+Mark+KRaft+as+Production+Ready
- https://blogsarchive.apache.org/kafka/entry/what-rsquo-s-new-in
- https://kafka.apache.org/blog/2025/03/18/apache-kafka-4.0.0-release-announcement/
- Name origin (joke about the "zoo" of animal-named projects at Yahoo!): found only in secondary sources, to check in the O'Reilly book "ZooKeeper" (Junqueira, Reed, 2013).
- Date the creation of the SourceForge project, and confirm the 3.0.0 announcement date (only the archive upload date is known).
- Source when Kafka started using ZooKeeper, and ZooKeeper's role in YARN ResourceManager high availability.
- Pin down the exact date of the paper's presentation at USENIX ATC 2010.