Coordination metadata is different from application data#
Schedulers, partition managers, and service registries sometimes need participants to agree on current membership or authority. ZooKeeper provides a hierarchical namespace of small znodes, sessions, watches, and ordering primitives. It is not a general database for profiles, orders, or large payloads.
Znodes, sessions, ephemeral state, and watches#
Persistent znodes remain until changed or deleted. Ephemeral znodes are tied to a client session and can represent live membership. Standard watches are one-time triggers; clients re-read state and re-establish observation rather than treating a notification as a complete event log.
Build patterns from recipes, not timing assumptions#
| Pattern | Primitive intuition | Failure question |
|---|---|---|
| Membership | Ephemeral registration | What happens during disconnection or session expiration? |
| Leader election | Ordered contender nodes and one selected owner | How is stale leadership fenced? |
| Configuration | Persistent metadata plus watch/re-read | Can clients safely run with old configuration? |
An ensemble requires quorum to coordinate#
ZooKeeper replicates its ordered state across an ensemble and needs a quorum for progress. A client that loses its session must behave conservatively: an old process may no longer own an ephemeral registration or leadership position. Cross-link leases and fencing; a notification alone does not revoke external side effects.
- Storing large or high-volume application data in ZooKeeper.
- Treating one-shot watches as a durable stream of every change.
- Assuming a disconnected client still owns leadership.
- Implementing election recipes without handling session expiration and stale actors.
- Explaining Zab internals when the interview asks why coordination storage exists.
Use these prompts to extend the design. The useful answer is a reasoned change, not a memorized sentence.
- What metadata truly requires strong coordination?
- What happens when the client disconnects?
- How does a new leader prevent an old leader from writing?
- Can the system degrade without the ensemble?
- Why not use an application database?
Related practice problems
Use the manifest-backed prompts below to apply this lesson in a complete design.
- ZooKeeper Programmer's GuideApache ZooKeeper Documentation