Zookeeper medium
You need to implement a Distributed Queue where multiple producers push tasks. How does the 'Sequential' Znode flag provide the necessary ordering primitive?
- A It forces the leader node to buffer incoming requests until a majority of followers reach a consistent timestamp.
- B It automatically appends a monotonically increasing counter to the Znode name (e.g., `task-0000000001`), ensuring a total global order within the parent path.
- C It sorts the underlying transaction log by the client's session ID to prevent out-of-order execution.
- D It prevents duplicate writes by hashing the data payload and mapping it to a unique integer ID.
Answer: B. It automatically appends a monotonically increasing counter to the Znode name (e.g., `task-0000000001`), ensuring a total global order within the parent path.
Sequential nodes are the foundation of ordering in ZK. By creating `task-` with the sequence flag, ZK ensures every item gets a unique, sortable ID, acting as the queue index.
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?