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

查看:26
本文介绍了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 synchronously 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. 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天全站免登陆