Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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?

like image 542
Rajat Gupta Avatar asked Jan 03 '11 12:01

Rajat Gupta


1 Answers

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.

like image 158
Apurva Singh Avatar answered Oct 10 '22 20:10

Apurva Singh