Meaning of eventual consistency in Cassandra?

Rajat Gupta picture Rajat Gupta · Jan 3, 2011 · Viewed 11.4k times · Source

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?

Answer

Apurva Singh picture Apurva Singh · Mar 4, 2017

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 mechanism in background 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.