Free sample lesson · ZooKeeper for Engineers: The 5 Core Use Cases
What ZooKeeper Is (and Isn't)
Lesson 1 of the Wondering course ZooKeeper for Engineers: The 5 Core Use Cases
A Coordinator, Not a Database
ZooKeeper is a coordination service for distributed systems.
Its job is helping many machines agree: who is the leader, which nodes are alive, who holds a lock.
It is not a place to store your application data. That mistake causes most ZooKeeper failures in production.
- Coordination service
- General-purpose database
The Znode Tree
ZooKeeper stores everything in a tree of znodes, much like a filesystem.
Each znode has a path, such as /services/api/leader, and can hold a small piece of data.
A znode can also have children, so the tree gives you natural grouping: all locks under one branch, all live members under another.
- /: The root of the znode tree.
- /services: A branch grouping service coordination data.
- /services/api
- /locks: All locks live under one branch.
- /members: All live members live under another branch.
The 1MB Limit
Every znode carries a hard size limit: 1MB of data.
That sounds restrictive until you remember what belongs there. A hostname, a lock owner, a config flag, a leader identifier.
All of those fit in a few hundred bytes. The limit is a guardrail, telling you when you have started storing the wrong kind of thing.
Why Small Data Matters
ZooKeeper copies every write to every server in the ensemble before confirming it.
That agreement is what makes the data trustworthy, and it is also what makes it expensive.
Large values would slow every member down at once. Small, coordination-only data keeps that agreement fast.
- Write arrives: A client sends a small update to a znode.
- Copy out: ZooKeeper copies the write to every server in the ensemble.
- Agree: The ensemble agrees on the value before it is confirmed.
- Stay fast: Small data keeps that agreement cheap for every member.
Redis and Cassandra Are Different
Redis and Cassandra are built to hold application data at volume.
ZooKeeper is built to hold tiny facts that many machines must agree on.
Putting user sessions or event records in ZooKeeper is using a coordination service as a storage engine, and it will not end well.
- ZooKeeper
- Redis
- Cassandra
A Test Before You Write
Before putting anything in a znode, ask one question. Does every machine need to agree on this fact?
If yes, and it fits in a few hundred bytes, ZooKeeper is the right home.
If it is application data, or if it is pushing toward 1MB, send it to Redis or Cassandra instead.
- New piece of data
- Must all agree?: Does every machine need to agree on this fact?
- Only a few hundred bytes?: Coordination values stay far below 1MB.
- Store in znode
- Redis or Cassandra: Application data belongs in a storage engine.
Check yourself
Is ZooKeeper intended to store user sessions and event records as application data?
- Yes
- No
Answer: No
No. ZooKeeper is a coordination service for shared facts such as leaders, locks, and live nodes. User sessions and event records belong in an application-data store such as Redis or Cassandra.
ZooKeeper is a _____ for distributed systems; Redis and Cassandra are built to hold _____ at volume.
Answer: ZooKeeper is a coordination service for distributed systems; Redis and Cassandra are built to hold application data at volume.
ZooKeeper stores tiny facts that machines must agree on, while Redis and Cassandra are designed for high-volume application data.
Why does ZooKeeper keep coordination values small?
- Every write is copied to every server before confirmation.
- Large values cannot be represented in a znode tree.
- Redis and Cassandra reject values larger than a few hundred bytes.
- Small values prevent znodes from having child nodes.
Answer: Every write is copied to every server before confirmation.
ZooKeeper copies every write to every server in the ensemble before confirming it. Larger values would therefore slow all members during agreement, while small values keep coordination fast.
Keep going
This is lesson 1 of 9 in ZooKeeper for Engineers: The 5 Core Use Cases. Next up:
- The Primitives: Ephemeral Nodes, Sequential Nodes, and Watchers
- Use Case 1: Distributed Configuration Management
- Use Case 2: Leader Election
- Use Case 3: Distributed Locking
- Use Case 4: Service Registry and Cluster Membership
Wondering turns any topic into short lessons you can read, watch, or listen to, with practice questions and an AI tutor.