12

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.

vishr
  • 985
  • 10
  • 28

3 Answers3

9

The suggested Consistency Level for lightweight transactions is SERIAL. Behind the scenes however SERIAL is even worse than QUORUM, because it's a multi-phase QUORUM. As you said the situation can get hard to handle when you have multiple DC -- Datastax estimate "effectively a degradation to one-third of normal".

There is a LOCAL_SERIAL that could be perfect for your situation where all DCs receive data from a specific DC.

Here you can find more info:

LIGHTWEIGHT TRANSACTIONS
LINEARIZABLE CONSISTENCY

HTH,Carlo

Carlo Bertuccini
  • 19,615
  • 3
  • 28
  • 39
  • 3
    From what I understood SERIAL consistency level makes sense for reads and not writes. I'm still unsure if changing consistency level in lightweight transactions has any effect at all. – Rafael Almeida Oct 13 '16 at 09:43
1

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.

DavidInTx
  • 94
  • 4
0

Actually a Quorum will be slightly more than one half of the Replication factor of your cluster. In practice, Replication factors are usually kept low (3 or 5), so as to avoid wasting space.

Ranjan
  • 31
  • 4