Zookeeper medium
A ZooKeeper client reads data from a Follower that is slightly lagging. How can the client ensure it receives the absolute latest state from the Leader?
- A Invoke a `sync()` command before the read; this forces the Follower to synchronize its state with the Leader before returning data.
- B Wait for at least 5 `tickTime` intervals to ensure the ZAB protocol has propagated all pending transaction logs.
- C Perform a recursive checksum validation of the parent Znode to detect if the local replica is stale.
- D Initialize a new TCP connection directly to the Leader's 2181 port and bypass the Follower entirely.
Answer: A. Invoke a `sync()` command before the read; this forces the Follower to synchronize its state with the Leader before returning data.
ZooKeeper reads are fast because they don't involve the Leader. They are 'Linearly Consistent' locally but can be stale globally. `sync` bridges this gap.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- What is the primary technical function of a ZooKeeper 'Watch'?
- A system administrator increases `jute.maxbuffer` to 5MB on every ZooKeeper server to store large configuration objects. However, write operations larger than 1MB still fail. What is the most likely cause?
- By default, `forceSync` is enabled. If you disable it, what trade-off are you making?
- If the specific ZooKeeper node a client is connected to crashes, what should the client do?
- Which cluster configuration has *worse* availability: A 3-node cluster or a 4-node cluster? (Assuming simple majority quorum)
- According to the CAP Theorem, how is ZooKeeper classified?