gpt4 book ai didi

apache-zookeeper - ZooKeeper 在 CAP 定理方面总是一致的吗?

转载 作者:行者123 更新时间:2023-12-04 01:56:03 25 4
gpt4 key购买 nike

ZooKeeper 始终是 CP 是否正确(根据 CAP 定理)?
或者无论如何将它用作服务发现需求的AP?

最佳答案

Zookeeper不是A,也不能掉P,所以明明叫CP。就 CAP 定理而言,“C”实际上意味着线性化。

linearizability : if operation B started after operation A successfully completed, then operation B must see the the system in the same state as it was on completion of operation A, or a newer state.



但,
Zookeeper有 顺序一致性 - 来自客户端的更新将按照它们发送的顺序应用。

ZooKeeper 实际上并没有在客户端 View 之间同时保持一致。
http://zookeeper.apache.org/doc/trunk/zookeeperProgrammers.html#ch_zkGuarantees

ZooKeeper does not guarantee that at every instance in time, two different clients will have identical views of ZooKeeper data. Due to factors like network delays, one client may perform an update before another client gets notified of the change. Consider the scenario of two clients, A and B. If client A sets the value of a znode /a from 0 to 1, then tells client B to read /a, client B may read the old value of 0, depending on which server it is connected to. If it is important that Client A and Client B read the same value, Client B should should call the sync() method from the ZooKeeper API method before it performs its read.



ZooKeeper 提供“顺序一致性”。这比线性化弱,但仍然非常强大,比“最终一致性”强得多。 ZooKeeper 还提供了一个同步命令。如果您调用同步命令然后读取,则可以保证读取至少看到在同步开始之前完成的最后一次写入。
linearizability ,写入应该是瞬时的。不准确地说,一旦写入完成,所有后续读取(其中“稍后”由挂钟开始时间定义)应该返回该写入的值或稍后写入的值。一旦读取返回特定值,所有后续读取都应返回该值或后续写入的值。”

在 Zookeeper 中,他们有 sync() 方法可以在我们需要线性化之类的地方使用。
Serializability是关于事务或对一个或多个对象的一个​​或多个操作组的保证。它保证在多个项目上执行一组事务(通常包含读取和写入操作)等效于事务的某些串行执行(总排序)。

引用 :
  • http://zookeeper-user.578899.n2.nabble.com/Consistency-in-zookeeper-td7578531.html
  • http://www.bailis.org/blog/linearizability-versus-serializability/
  • Difference between Linearizability and Serializability
  • 关于apache-zookeeper - ZooKeeper 在 CAP 定理方面总是一致的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35387774/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com