在Cassandra提供交易支持

时间:2016-08-17 09:30:41

标签: transactions cassandra couchbase

我们有一个用例,我们需要编写/更新两个具有事务支持的表。这是必需的,因为两个表都是相关的,因此它们不能同步。 我们还讨论过合并两个表,但这看起来不太可行。

AFAIK,Cassandra并不提供开箱即用的交易支持。有没有可用的技术/库?

我们也正在评估Couchbase。你认为沙发基地比卡桑德拉更好吗?

3 个答案:

答案 0 :(得分:3)

Cassandra supports per-key linearizability and compare-and-set (CAS). It's enough for implementing transactions on the client side.

Percolator's transactions provides serializable isolation level. They are quite known in the industry and are in use in the Amazon's DynamoDB transaction library, in the CockroachDB database and in the Google's Pecolator system itself. A step-by-step visualization of the Percolator's transactions may help you to understand them.

If you expect contention and can deal with Read Committed isolation level then RAMP transactions by Peter Bailis may suit you. I also created a step-by-step RAMP visualization which may be useful for understanding.

The third approach is to use compensating transactions also known as the saga pattern. It was described in the late 80s in the Sagas paper but became more relevant with the rise of distributed systems. Please see the Applying the Saga Pattern talk for inspiration.

答案 1 :(得分:2)

Cassandra仅在单个分区(单个表)中支持事务。查看可能对您有所帮助的批量查询:http://docs.datastax.com/en/cql/3.1/cql/cql_reference/batch_r.html

答案 2 :(得分:2)

在Couchbase中,您可以将RDMBS中三个不同表中的内容组合成一个JSON文档,因此不需要事务。在不知道你的应用程序的情况下,我无法知道一个好的JSON文档模型应该是什么。将关系模式与NoSQL模式进行比较的是苹果到橙子。

在相关的说明中,当您编写单个对象时,Couchbase非常一致。您的读/写总是转到相同的活动vBucket(即分片)。