4

I'm new to Cassandra. Let's assume I have 3 nodes and Replication Factor(RF) of the keyspace is 3.

  1. Can I safely assume that if 2/3 nodes are down, I still get the complete data for a query irrespective of the Consistency level?
  2. Keeping 2/3 nodes as down, which consistency level will assure me the complete data for a query?
Michael0x2a
  • 58,192
  • 30
  • 175
  • 224
Guda uma shanker
  • 183
  • 1
  • 13

2 Answers2

3

It depends on what consistency level you've used for write and read 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 care R + W <= 3
Now lets say, we have used QUORUM for read operations and ONE for write.

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

You can configure consistency level according to needs but keep latency in mind.
You can read about that more consistency-handing and consistency-configuration

Coming back to you question, if only one node was being used then you wouldn't have an eventual consistency. You can use ONE for both read and write but it will defeat the purpose. Assuming nodes will be up again, I'd rather user LOCAL_QUORUM for write and TWO for read.

Bigby
  • 321
  • 5
  • 16
  • So if I write to the table(RF is 3) with write consistency as ONE, does Cassandra replicate my data or not? – Guda uma shanker Aug 08 '17 at 15:22
  • Yes it will, given the nodes are up in time. You should read this concept [hinted-handoff](http://docs.datastax.com/en/archived/cassandra/2.0/cassandra/dml/dml_about_hh_c.html) It's pretty critical in understanding what happens to read/writes when you have some nodes down. – Bigby Aug 10 '17 at 15:42
0

In your case, since there are 3 nodes and the replication factor is also 3, therefore, each node will have all the data. Therefore, even if only 1/3 node is operational, you'll still be able to fetch the complete data. However, the consistency of the data(i.e. whether you get the latest data or not) will, in this case, depend on the write consistency used(I'm assuming that since only 1/3 node is operational, therefore the read consistency is 1). In order, to get consistent data, the write consistency should be 3(Using the condition, R+W>N for strong consistency). Only then will you get consistent data while reading even when only 1/3 node is operational.

Vishal Sharma
  • 1,670
  • 20
  • 55