Cassandra 中最终一致性的含义是什么?

发布于 2024-10-10 06:28:39 字数 127 浏览 2 评论 0原文

当单个集群中的节点不包含相同数据的副本但数据分布在节点之间时,Cassandra 中的最终一致性意味着什么。现在,由于单个数据记录在单个位置(节点)。为什么 Cassandra 不从该单一记录位置返回最近的值?在这种情况下如何产生多个副本?

What is the meaning of eventual consistency in Cassandra when nodes in a single cluster do not contain the copies of same data but data is distributed among nodes. Now since a single peice of data is recorded at a single place (node). Why wouldn't Cassandra return the recent value from that single place of record? How do multiple copies arise in this situation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

小瓶盖 2024-10-17 06:28:39

Cassandra 的一致性是可调的。可以调什么?

  • 需要就读取数据达成一致的节点数量...称为 R
  • 需要就写入数据达成一致的节点数量...称为 W

在 3 个节点的情况下,如果我们选择 2R 和 2W,则在请阅读,如果 2 个节点对某个值达成一致,则该值就是真实值。第三个值可能相同,也可能不同。

写入时,如果选择2W,那么数据写入2个节点就足够了。这个模型是一致的。

如果R+W> N,其中N是节点数,最终会保持一致。

Cassandra 维护每列和列的每个字段的时间戳,以最终保持一致。有一个后台机制来达到一致的状态。
但就像我说的,如果 R + W > N,则为一致固体。这就是为什么 Cassandra 中一致性被认为是可调的。

必须在某个时刻达到完全一致性。这可以使用读修复来完成,即在从 3 个节点读取期间,其中 2 个返回值,而第 3 个节点已过时,然后 cassandra 可以在第 3 个节点上执行修复。这也可以不时通过批处理作业来完成。

Cassandra's consistency is tunable. What can be tuned?

  • Number of nodes needed to agree on the data for reads... call it R
  • Number of nodes needed to agree on the data for writes... call it W

In case of 3 nodes, if we chose 2R and 2W, then during a read, if 2 nodes agree on a value, that is the true value. The 3rd may or may not have the same value.

In case of write, if 2W is chosen, then if data is written to 2 nodes, it is considered enough. This model IS consistent.

If R + W > N where N is number of nodes, it will be eventually consistent.

Cassandra maintains a timestamp with each column and each field of column to eventually become consistent. There is a background mechanism to reach a consistent state.
But like I said, if R + W > N, then it is consistent solid. That is why consistency is considered tunable in Cassandra.

Full consistency has to be reached at some point. This can be done using read repair i.e. during a read from say 3 nodes, 2 return a value, and 3rd is out of date, then a repair can be performed by cassandra on the 3rd node. This can also be done by a batch job from time to time.

铁轨上的流浪者 2024-10-17 06:28:39

由客户端决定适当的一致性级别(零、任意、一、法定人数或全部)。
(一致性级别根据您的复制因子控制读取和写入行为。)
在单节点集群中,一致性级别any、one、quorom 和all 是等效的。

Its up to the client to decide the appropriate consistency level (zero, any, one, quoram or all).
(The consistency level controls both read and write behavior based on your replicationfactor.)
In a single node cluster the consistency levels any, one, quorom and all are equivalent.

晨曦慕雪 2024-10-17 06:28:39

即使复制因子 = 1,一致性也不一定是立即的,因为写入会在您将其发送到的节点上进行缓冲,因此不一定会立即发送到负责该密钥的节点。

但这取决于您选择的一致性级别。

Cassandra 的主要用例是复制因子 > 1,这就是一致性变得更重要的问题。 RF=3 似乎是一种常见设置(因为它允许在一个节点不可用的情况下进行 Quorum 读/写)

Even with replication factor = 1, consistency is not necessarily immediate because writes are buffered on the node that you send them to and hence don't necessarily immediately get sent to the node responsible for that key.

But it depends on what consistency level you choose.

Mostly the use-case for Cassandra is with replication factor > 1, which is where consistency becomes more of an issue. RF=3 seems to be a common setting (as it allows Quorum reads/writes with one node unavailable)

月依秋水 2024-10-17 06:28:39

这是关于最终一致性的一个很好的解释:

Here is a nice explain about eventually consistent:
http://www.allthingsdistributed.com/2008/12/eventually_consistent.html

淡淡绿茶香 2024-10-17 06:28:39

Cassandra 往往会为了可用性而牺牲延迟和一致性。它是“最终一致”的,是与分布式设置一起使用的 NoSQL 数据库一致性模型。最终一致性不是维持严格的一致性,这实际上会在规模上减慢速度,而是可以实现高可用性,但代价是每个数据实例不能立即在所有服务器上同步。

Cassandra tends to compromise latency and consistency for availability. It’s “eventually consistent,” a model for NoSQL database consistency that’s used with distributed setups. Rather than maintain strict consistency that could really slow things down at scale, eventual consistency enables high availability—just at the cost of every instance of your data not being synced up across all servers right away.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文