简体   繁体   English

最终在Cassandra中的一致性是什么意思?

[英]Meaning of eventual consistency in 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. 当单个群集中的节点不包含相同数据的副本但数据在节点之间分布时,Cassandra中最终一致性的含义是什么。 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? 为什么Cassandra不从单个记录位置返回最近的值? How do multiple copies arise in this situation? 在这种情况下如何产生多份副本?

Cassandra's consistency is tunable. Cassandra的一致性是可调的。 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 *同意用于读取的数据的节点数。称其为R *同意用于写入的数据的节点数。称其为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. 在3个节点的情况下,如果我们选择2R和2W ..那么在读取期间,如果2个节点都同意一个值,那就是真实值。 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. 在写入的情况下,如果选择2W,则如果将数据写入2个节点,则认为足够了。 This model IS consistent. 该模型是一致的。
If R + w <= N where N is number of nodes, it will be eventually consistent. 如果R + w <= N,其中N是节点数,则最终将保持一致。
Cassandra maintains a timestamp with each column and each field of column to eventually become consistent. Cassandra为每个列和每个列的字段维护一个时间戳,以最终变得一致。 There is a mechanism in background to reach a consistent state. 在后台有一种机制可以达到一致的状态。
But like I said, if R + W > N, then it is consistent solid. 但是就像我说的那样,如果R + W> N,那么它是一致的固体。 That is why consistency is considered tunable in Cassandra. 这就是为什么一致性在Cassandra中被认为是可调的。

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. 即使复制因子= 1,一致性也不一定是立即的,因为写入会在发送到的节点上进行缓冲,因此不一定会立即发送到负责该密钥的节点。

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. 大多数情况下,Cassandra的用例的复制因子> 1,这在一致性方面变得更加重要。 RF=3 seems to be a common setting (as it allows Quorum reads/writes with one node unavailable) RF = 3似乎是一个常见设置(因为它允许Quorum读/写,而一个节点不可用)

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. (一致性级别基于您的复制因子控制读取和写入行为。)在单节点群集中,任何,一个,全部和全部的一致性级别是等效的。

这是有关最终一致性的很好的解释: http : //www.allthingsdistributed.com/2008/12/eventually_consistent.html

Cassandra tends to compromise latency and consistency for availability. Cassandra倾向于牺牲延迟和可用性的一致性。 It's “eventually consistent,” a model for NoSQL database consistency that's used with distributed setups. 它“最终是一致的”,这是用于分布式设置的NoSQL数据库一致性模型。 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. 最终的一致性并没有维持可能会导致规模缓慢降低的严格一致性,而是提高了可用性,只是以不立即在所有服务器之间同步数据的每个实例为代价。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM