Zookeeper read/write

Apache ZooKeeper is a kind of high available data-store for small objects. A ZooKeeper cluster consists of some nodes which all keep the whole dataset in their memory. The dataset is called "always-consistent", so every node has the same data at every time.

Zookeeper read/write operators.

Reads
are always answered locally by the node, so no communication with the cluster is involved.
Writes
are forwarded to a designated "Leader" node, which forwards the write-request to all nodes and waits for their replies. If at least half of the nodes answers, the write is considered successful.

weak-consistency/strong-consistency
In order to achieve high read-availability, Zookeeper guarantees a weak-consistency over the replicates: a read can always be answered by a client node, and the answer returned may be a stale value (even a new version has been committed through the leader).

Then it is the users' responsibility to decide whether the answer for a read is "stale-able" or not, since not all applications require the up-to-date information. So the following choices are provided:

  1. If your application does not need up-to-date values for reads, you can get high read-availability by requesting data directly from the client.

  2. If your application requires up-to-date values for reads, you should use the "sync" API before your read request to sync the client-side version with the leader.

So as a conclusion, Zookeeper provides a customizable consistency guarantee, and users can decide the balance between availability and consistency.

More Info

If you want to know more about the internals of Zookeeper, I recommend this paper: ZooKeeper: Wait-free coordination for Internet-scale systems. The above strategy is described in Section 4.4.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 我的个人博客 http://yedingding.com 会更新 Teahour.fm 的最新音频文本,欢迎关注。...
    叶玎玎阅读 1,603评论 0 2
  • 大多数文艺小青年都有个梦想,那就是写上一本属于自己的小说,可是每次都会以拖延症粉碎自己的梦想。 做了就做了,让它随...
    书上熊阅读 364评论 0 1
  • 不知从何时起,后知后觉的我发现柔宝爱讲故事了,昨晚说…妈妈,我给你两个故事,你给我讲两个故事好吗?本来又困又累的我...
    东泽666阅读 87评论 0 0
  • 因为人是群居动物 所以茫茫人海中总会有一个人抓住平凡的你 再爱上你的平凡
    阿然胃里住了一只猪阅读 294评论 0 0
  • “叮铃铃——” 校园的铃声在十二点钟准时响起,上了一上午课程的学生们匆匆的收拾一番,便前往食堂。 此时,已有雨丝缓...
    洛荨阅读 416评论 0 1