ZooKeeper
Overview
Core Concepts
Znodes (Data Nodes)
/
├─ /app
│ ├─ /app/config
│ └─ /app/leader
├─ /services
│ ├─ /services/service1
│ └─ /services/service2Znode Types
1. Persistent
2. Ephemeral
3. Sequential
Architecture
Ensemble (Cluster)
Leader & Followers
ZAB (ZooKeeper Atomic Broadcast)
Purpose
Two Phases
1. Discovery Phase
2. Broadcast Phase
Write Flow
ZXID
Session Management
Client-Server Session
Session States
Session Expiry
Watches (Notifications)
One-Time Triggers
Watch Types
Consistency Model
Sequential Consistency
Guarantees
Common Use Cases
1. Leader Election
2. Distributed Lock
3. Service Discovery
4. Configuration Management
Performance Characteristics
Read Throughput
Write Throughput
Failure Scenarios
Follower Failure
Leader Failure
Network Partition
Tuning & Best Practices
Session Timeout
Data Size
Ensemble Size
Avoid Watches on Large Child Lists
Common Pitfalls
❌ Using ZooKeeper as Database
❌ Not Handling Session Expiry
❌ Herd Effect
❌ Blocking in Watch Callback
Comparison: ZooKeeper vs etcd
Feature
ZooKeeper
etcd
Interview Questions
Last updated