Search code examples
cassandracassandra-2.0data-consistency

Cassandra Consistency Level and Replication Factor


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?

Solution

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