The following content is mainly excerpt from <
Zookeeper is a high-performance, scalable service. Zookeeper Read and write very fast, and the reading speed is faster than writing. In addition, ZooKeeper still has the ability to serve old data while reading. These are due to the consistency guarantee provided by Zookeepe, which has the following characteristics:
"The consistency provided by zookeeper is weak consistency, and the first data replication has the following rules: Zookeeper ensures that every modification to the Znode tree is replicated to more than half of the machines in the collection. Then it is possible that the data of the node is not up-to-date and is accessed by the client. And there will be a point in time that is inconsistent in the cluster.
That is, zookeeper only guarantees eventual consistency, but real-time consistency can be guaranteed by the client calling itself, by calling the sync () method.
】
Sequential consistency
The order in which clients are updated is consistent with the order in which they are sent.
Atomic Nature
The update operation either succeeds or fails with no third result.
Single-System mirroring
No matter which server the client connects to, the client will see the same ZooKeeper view.
"How can you guarantee to see the same view if the data is inconsistent?" Insert/delete/modify will have an impact on the data structure "
Reliability
Once an update operation is applied, its value will not change until the client updates it again. This guarantee will produce the following two results:
1. If the client successfully obtains the correct return code, then the update has been made. If the return code cannot be obtained (due to communication errors, timeouts, and so on), then the client will not know whether the update operation takes effect.
2. When recovering from a failure, any client can see that the successful update operation will not be rolled back.
Real-time sex
For a certain period of time, the client sees that the system needs to be guaranteed to be real-time (in more than 10 seconds). During this time period, any changes to the system will be seen by the client or detected by the client.
"Pseudo-real-time, too misleading, straightforward point is that the data can be in more than 10 seconds sync to each node, to ensure eventual consistency. " The first time I saw this real-time, I was curious, Oracle RAC spent the old nose to ensure the real-time and consistency, zookeeper is how easy to do, the original is a fake, but also said that people misunderstanding. "
Given these consistency guarantees, the design and implementation of ZooKeeper's more advanced features will become very easy, such as the implementation of leader elections, queues, and revocable locks.
【
The zookeeper is analyzed using the cap principle of the distributed system.
1) C:zookeeper guarantees final consistency and can sync to each node in more than 10 seconds.
2) A:zookeeper guarantees availability, data is always available, no locks. And the data that has the more than half node is up-to-date, real-time. If you want to make sure the data is up to date, you need to call sync manually ()
3) P: There are 2 points to analyze.
A large number of nodes can cause write data to be delayed very much because multiple nodes need to be synchronized.
More nodes leader the election is very time consuming, it amplifies the problem of the network. This problem can be mitigated by introducing observer nodes.
】
Http://www.cnblogs.com/lpshou/archive/2013/06/14/3136904.html
Reprinted blog: http://flyfoxs.iteye.com/blog/2121560
"Big Data Notes" vernacular zookeeper consistency