Apache ZooKeeper
medium 30 minZooKeeper is a small, replicated, strictly ordered tree of notes that programs use to coordinate: who is the leader, who is alive, who holds a lock, what the settings are.
Remember it
The few things worth knowing cold, and how to make them stick.
Memory hook
Notes on the tower board that vanish when their writer leaves.
A council keeps three equal boards. Two of three must hold a note before it counts. The baker's note fades when the sand timer runs out.
Cheat sheet
- Is
- ordered tree for coordination, CP
- Majority
- floor(N/2) + 1
- Znode limit
- just under 1 MB
- Session
- 2 to 20 ticks (4 to 40 s)
- Reads
- local; sync for fresh
- Watch
- once; persistent since 3.6
- zxid
- epoch + counter, 32 bits each
- Ports
- 2181, 2888, 3888
- Paper, 3 servers
- 87k reads/s or 21k writes/s
Spot it when you see
- One active leader
- Who is alive?
- Hadoop, HBase, Solr
Tricks that stick
- E for ephemeral: exits with its maker.
- S for sequential: stands in line.
- Watch the one in front, like any queue.
Do not forget
- Storing data
- Counting watch events
- Trusting a lock without fencing
- No autopurge
- Log and snapshots on one busy disk