3

It's not easy to design a notification/push service for a decentralized (peer-to-peer) cluster. For example, if I want Cassandra to push out a notification to Service A, if one table field has changed its value by Service B, that's not easy. This is because Cassandra is organized in a decentralized manner, e.g., 5 nodes, and they don't know when a quorum of three nodes are committed before pushing the change to A. However, in a centralized (master-slave) cluster, things are different. ZooKeeper, for example, knows when 3 nodes out of the 5 are committed, and a notification service can be arranged.

How can we design such a push service in a decentralized cluster?

One obvious solution would be waiting for a certain period of time (say, 10 seconds) and notify B regardless.

Another option: If Service B has received 3 acks from Cassandra that the quorum has been satisfied, B then would send out the notification to A instead of Cassandra itself sending it.

Are there any other decent solutions?

Filip Haglund
  • 13,919
  • 13
  • 64
  • 113
Fan Zhang
  • 59
  • 7

2 Answers2

3

You can use Cassandra consistency level. It's like waiting some period of time, but this way you are sure to have the right data.

With a small example:

Write

Imagine you have a RF of 3, then on the write, if you put a consistency level of 3, you need the answer of 3 computers (that write the data) to validate a write which make it consistent.

READ

You can set this argument to all, but the greater the required count, the slower it will be. I think as many machines as the RF is fine, so you can compare all timestamp from the different replicas.

There are some predefined consistency levels. To have a better understanding of this, read the following documentation:

https://docs.datastax.com/en/cassandra/2.0/cassandra/dml/dml_config_consistency_c.html

This mechanism slows Cassandra, because Cassandra is not made to be consistent, but instead to be available. If you want consistency, look at HBase or MongoDB.

seh
  • 14,999
  • 2
  • 48
  • 58
Whitefret
  • 1,057
  • 1
  • 10
  • 21
2

I think what you want is Change Data Capture, which will be released in a future version of Cassandra.

https://issues.apache.org/jira/browse/CASSANDRA-8844

Jon Haddad
  • 766
  • 6
  • 17