在Consistency Guarantees ZooKeeper 程序员指南的部分,它指出 ZooKeeper 将提供“单一系统镜像”保证:
A client will see the same view of the service regardless of the server that it connects to.
根据ZAB协议(protocol),只有超过半数的follower认可一个提议,leader才能提交交易。因此,很可能并非所有关注者都处于相同状态。
如果follower的状态不一样,ZooKeeper如何保证“单一系统状态”?
引用资料:
最佳答案
领导者仅等待来自法定人数的追随者的响应以确认提交交易。这并不意味着一些追随者不需要承认交易或可以“说不”。
最终,当其余的追随者处理来自领导者的提交消息或作为同步的一部分时,将具有与主人相同的状态(有一些延迟)。 (不要与最终一致性混淆)
follower状态能延迟多长时间取决于配置项syncLimit & tickTime ( https://zookeeper.apache.org/doc/current/zookeeperAdmin.html )
跟随者在被丢弃之前最多可以落后 syncLimit * tickTime 时间单位。
关于apache-zookeeper - ZooKeeper 如何保证 "Single System Image"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40797443/