Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

nw avatar image
nw asked Erick Ramirez answered

How can we handle lightweight transactions with SERIAL consistency during a DC outage?

Hello,

Please share your comments on the following:

We have an application that needs unique value (2 byte integer) for a transaction.

This application is multithreaded and multiple instances are run parallelly. Each application or thread should have unique transactionid. Application will check the current value in Cassandra, increment it by one and using LWT updates the value in column.

As multiple instances are updating the same column, SERIAL consistency is used to make sure transaction ID is unique.

Because of this LWT and SERIAL consistency we are having the following issues:

1. Latency - A single LWT is getting failed multiple times to get one unique transaction.

2. DC failover - If a node or a DC goes down, because of serial consistency transaction's are getting failed in Cassandra.

Cassandra configuration:

6 Node cluster --> 2 Data centers each with 3 nodes and replication factor of 2. Each DC have 3 client applications.

How to achieve low latency and handle failover?

Thanks

lightweight transactions
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

steve.lacerda avatar image
steve.lacerda answered

SERIAL is similar to QUORUM in that it would require:

total replication / 2 + 1 = nodes

In your case:

6 / 2 + 1 = 4 nodes

Instead of using SERIAL, I would recommend using LOCAL_SERIAL, and then handling the ERROR with retries just like you would with LOCAL_QUORUM. Using LOCAL_SERIAL will help with latencies and thus the timeouts that you're seeing as well since you'll be reducing the number of nodes required for the read to ack. Additionally, that would remove the hop across the DC, which will also help latencies.

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered

Unfortunately since there are multiple clients actively writing to both DCs, LOCAL_SERIAL is not an option for you.

You do not have any choice but to use SERIAL consistency. It does mean that your applications cannot tolerate an outage to the DC but it provides guarantees in situations where the network is partitioned temporarily (i.e. a network outage between DCs) -- none of the applications can create transaction IDs therefore guaranteeing that you'll never have duplicates. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.