Question-141: In case of writing the data how consistency work?
Answer: For write operation, the write consistency level specifies how many replicas must respond to write request before the write is considered successful. Write operation use hinted handoff to ensure writes to be completed when nodes are down or otherwise not responding to the write request.
Question-142: can you please explain detail how does read consistency and write consistency related with replication factor?
Answer: Let's assume R represent consistency level for read operations, W represent consistency level for write operation and N is the number of Replica or replication factor.
If you want strong consistency to be guaranteed then summation of, read consistency (R) and write consistency (W) should be more than replication factor (R + W > N)
Let's take an example, if replication factor is 3, then the total of both the read and write consistency should be at least 4. With this example we can say that if both read and write consistency level is set to 2, then it results in a strong consistency. Read as two consistency means, before returning result to the application or user. At Least two replicas should be verified out of three.
If we want that our write operation should be fast, then we can reduce the write consistency from 2 to 1. Which can give you high performance while writing the data, but at the same time you have to increase the read consistency to 3, to satisfy the formula. Which can affect the read performance. This the way you tune the consistency.
Eventual consistency can be achieved using the following formula
Summation of read consistency and write consistency should be less than or equal to number of replica or replication factor.
R + W <= N
Question-143: What do you mean by quorum consistency?
Answer: If acknowledgement is received during read or write operation from more than half replica then it is called quorum consistency level. For example, if you have replication factor as 3, then in case of quorum consistency level at least two replicas should be verified.
Question-144: Is Cassandra support ACID transactions?
Answer: No, Cassandra is not an ACID compliant database and does not support transaction with rollback or locking mechanism. However, it offers, atomic, isolated, and durable transaction with eventual and tunable consistency. And user can decide how strong or eventual they want each transaction’s consistency.
Cassandra database does not support joins and foreign keys, and consequently does not support consistency in terms of ACID. This is because, the Cassandra is designed for high read and write performance, keeping the high volume of data across various node in the cluster.
Question-145: Suppose you have a replication factor set as 3, now you send an insert statement where consistency level is quorum, and insert for one of the nodes fails, then what happens?
Answer: As in this case consistency level is quorum, so write request would be submitted to, two(majority) nodes in the cluster. If write at one of the nodes is successful and on another node it failed. Then client would be reported that write request failed. But the values which is correctly written on one of the nodes, would not be rolled back.