Zookeeper hard
Why does ZooKeeper perform 64MB block pre-allocation for Transaction Logs instead of using standard byte-by-byte file appends?
- A To minimize disk I/O latency by avoiding frequent inode metadata updates and ensuring sequential write performance.
- B To facilitate the background defragmentation of the local Znode metadata tree by the OS kernel.
- C To reserve adequate storage for anticipated future snapshots without competing for disk space during runtime.
- D It is a specialized workaround for a legacy JVM limitation regarding direct byte buffer expansion in 64-bit environments.
Answer: A. To minimize disk I/O latency by avoiding frequent inode metadata updates and ensuring sequential write performance.
ZK is IO-bound. If every 1KB write caused a file size change (metadata update), the disk would seek constantly. Pre-allocation keeps the disk head moving smoothly in one direction.
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?