ZooKeeper和任何分布式键值存储之间有什么区别? [英] What's the difference between ZooKeeper and any distributed Key-Value stores?

查看:150
本文介绍了ZooKeeper和任何分布式键值存储之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Zookeeper和分布式系统的新手,我自己也正在学习它.

I am new to zookeeper and distributed systems, and am learning it myself.

据我目前的了解,ZooKeeper似乎只是一个键值存储,其键是路径,值是字符串,这与Redis没什么不同. (显然,我们也可以使用斜杠分隔的路径作为redis中的键.)

From what I understand for now, it seems that ZooKeeper is simply a key-value store whose keys are paths and values are strings, which is nothing different from, say, Redis. (And apparently we can use slash-separated path as keys in redis as well.)

所以我的问题是,ZooKeeper与其他分布式KV商店之间的本质区别是什么?为什么ZooKeeper使用所谓的路径"作为键而不是简单的字符串?

So my question is, what is the essential difference between ZooKeeper and other distributed KV store? Why is ZooKeeper using so called "paths" as keys, instead of simple strings?

推荐答案

您正在将ZooKeeper的高级数据模型与其他键值存储区进行比较,但这并不是使它唯一的原因.从分布式系统的角度来看,ZooKeeper与许多其他键值存储(尤其是Redis)不同,因为它具有很强的一致性,并且可以在大多数群集连接时容忍故障.此外,当数据保存在内存中时,它们会被同步复制到大多数群集中并由磁盘支持,因此,一旦写入成功,它可以确保写入不会丢失(除非发生导弹袭击).这使得ZooKeeper对于存储少量任务关键状态(如配置)非常有用.

You're comparing the high level data model of ZooKeeper to other key value stores, but that's not what makes it unique. From a distributed systems standpoint, ZooKeeper is different than many other key value stores (especially Redis) because it is strongly consistent and can tolerate failures while a majority of the cluster is connected. Additionally, while data is held in memory, it's synchroniusly replicated to a majority of the cluster and backed by disk, so once a write succeeds it guarantees that write will not be lost (barring a missile strike). This makes ZooKeeper very useful for storing small amounts of mission critical state like configurations.

相反,Redis不是分布式系统,并且不能提供与ZooKeeper相同类型的保证,并且分布式的许多其他键值存储最终都是一致的.换句话说,不能保证一旦写入值,分布式系统中的所有其他进程都可以看到该值.

Conversely, Redis is not a distributed system and does not provide the same sorts of guarantees that ZooKeeper does, and many other key value stores that are distributed are eventually consistent. In other words, there's no guarantee that once a value is written all other processes in a distributed system can see that value.

最后,除了文件系统(如用于存储状态的接口)外,ZooKeeper还提供了相当低级的功能,可以解决更复杂的问题.有关此示例,请查看Apache Curator. Curator使用ZooKeeper的短暂节点(当创建它们的客户端断开连接时消失的节点)来构建诸如锁和领导者选举之类的东西,这对于协调分布式系统非常有用.因此,从这个角度来看,ZooKeeper的数据模型和相关功能可作为基元,可以在基元上构建用于分布式协调的高级工具.

Finally, in addition to the file system like interface for storing state, ZooKeeper provides fairly low level features on which more complex problems can be solved. For examples of this look at Apache Curator. Curator uses ZooKeeper's ephemeral nodes (nodes that disappear when the client that created them disconnects) to build things like locks and leader elections which are extremely useful for coordinating distributed systems. So, from that perspective ZooKeeper's data model and associated features serve as primitives on which higher level tools for distributed coordination can be built.

这篇关于ZooKeeper和任何分布式键值存储之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆