Cassandra Consistency Level and Replication Rate

I am new to Cassandra. Suppose I have 3 nodes and the replication factor (RF) in the keyspace is 3.

  • Is it safe to assume that if 2/3 of the nodes are omitted, I still get the complete data for the request regardless of the consistency level?
  • Storing 2/3 of the nodes as downstream, which consistency level will give me complete data to query?
+3


source to share


2 answers


It depends on the consistency level you used for the read and write requests.

For strong consistency: R + W > N    
For eventual consistency: R + W =< N, where     
    - R is the consistency level of read operations     
    - W is the consistency level of write operations    
    - N is the number of replicas 

      

In our help R + W <= 3
Now let's say we used QUORUM for read operations and ONE for write operations.



    quorum = (sum_of_replication_factors / 2) + 1 = (3/2) + 1 = 2     
    read = 1   
    R + W <=3 is satisfied in our case.

      

You can adjust the consistency level according to your needs, but ignore latency.
You can read about this for more consistency and configuration consistency

Coming back to you, if only one node were used then you would not have constant consistency. You can use ONE to read and write, but that will defeat the purpose. Assuming the nodes are up again, I would prefer to use LOCAL_QUORUM for writing and TWO for reading.

+2


source


In your case, since there are 3 nodes and the replication factor is 3, so each node will have all the data. So even if only 1/3 node is running, you can still get the complete data. However, the consistency of the data (i.e. getting the latest data or not) will in this case depend on the consistency of the write being used (I assume that since only 1/3 node works, so the read sequence is 1). To get consistent data, the write consistency must be 3 (using the condition R + W> N for strong consistency). Only then will you get consistent data while reading, even if only 1/3 node is running.



0


source







All Articles