Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consistency Level of Cassandra Lightweight transactions

I read about Cassandra 2's lightweight transactions. Is the consistency level of such a write always at QUORUM? Would this mean that even if I have a multi data center setup with 100s of nodes, then quorum of the entire cluster (majority of the row's replicas across all data centers) is involved? Won't this be really slow and wont it affect availability?

Can we do LOCAL_QUORUM or EACH_QUORUM consistency? This would be preferred if writers for data replicated across multiple data centers would always originate from a specific data center only.

like image 280
vishr Avatar asked Jul 27 '14 23:07

vishr


People also ask

What consistency does Cassandra provide?

Tunable consistency in Cassandra To address this problem, Cassandra maintains tunable consistency. When performing a read or write operation a database client can specify a consistency level.

What is Cassandra lightweight transaction?

Cassandra implements lightweight transactions by extending the Paxos consensus protocol, which is based on a quorum-based algorithm. Using this protocol, a distributed system can agree on proposed data additions/modifications without the need for a master database or two-phase commit.

What is consistency level in Cassandra?

The Cassandra consistency level is defined as the minimum number of Cassandra nodes that must acknowledge a read or write operation before the operation can be considered successful. Different consistency levels can be assigned to different Edge keyspaces.

How do I check my consistency level in Cassandra?

To set the consistency level for your current session, use the CONSISTENCY command from the cassandra shell (CQLSH). To see your current consistency level, just run CONSISTENCY; from the shell: ty@cqlsh> consistency; Current consistency level is ONE.


1 Answers

Formally, if the nodes read from and the nodes written from together are greater than the number of nodes (r + w > n), the highest level of consistency you can achieve is Causal consistency.

If you use quorum reads and writes in Cassandra, Causal consistency is what you are getting.

This means that if you have a write on a node (w1) and a read from a different node (r1), and then a write based on the read (w2), w2 is said to be causally dependent on w1. A causually consistent system will ensure that all nodes see w1 and then w2. and this is what QUORUM reads and writes provide. Reads and writes that are not part of a casual dependency are not ordered in any particular way. We therefore say that this system has a partial order.

If you need to do things like a uniqueness check, you need to do a Compare and Set operation. A compare and set operation requires a higher level of consistency: it requires linearizability. Linearizability imposes a total order of operations (reads and writes) to an object.

In Cassandra, Lightweight transactions are the mechanism you use to ensure Linearizability to a row, and are thus how you do uniqueness checks in Cassandra. Other systems (etcd, for example) allow for linearizability on the entire database system, not just a row. Such a system is said to have Strict Serializability.

like image 117
DavidInTx Avatar answered Oct 05 '22 12:10

DavidInTx