Cassandra how to increase or decrease a count without Counters?

Viewed 35

I've heard that Cassandra Counters are considered a bad practice due to performance concerns. Which is a pity as they seem ideal for scenarios where you want to update a count but avoid locks or clashes.

Assuming Counters are not an option what is a good practice? My initial though would be to read the existing value, update it in the code, and write it back to the db. But when run in parallel this approach could override itself. e.g. Current value is 9, thread A reads it and sets 10, but at the same time thread B also reads 9 and sets 10, meaning the end result is 10 rather than 11.

This is a common problem, often solved with locks/transactions in other dbs. What's the approach taken with Cassandra?

0 Answers
Related