Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read-your-own-writes consistency in Cassandra

Read-your-own-writes consistency is great improvement from the so called eventual consistency: if I change my profile picture I don't care if others see the change a minute later, but it looks weird if after a page reload I still see the old one.

Can this be achieved in Cassandra without having to do a full read-check on more than one node?

Using ConsistencyLevel.QUORUM is fine while reading an unspecified data and n>1 nodes are actually being read. However when client reads from the same node as he writes in (and actually using the same connection) it can be wasteful - some databases will in this case always ensure that the previously written (my) data are returned, and not some older one. Using ConsistencyLevel.ONE does not ensure this and assuming it leads to race conditions. Some test showed this: http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/per-connection-quot-read-after-my-write-quot-consistency-td6018377.html

My hypothetical setup for this scenario is 2 nodes, replication factor 2, read level 1, write level 1. This leads to eventual consistency, but I want read-your-own-writes consistency on reads.

Using 3 nodes, RF=3, RL=quorum and WL=quorum in my opinion leads to wasteful read request if I being consistent only on "my" data is enough.

// seo: also known as: session consistency, read-after-my-write consistency

like image 825
tillda Avatar asked Jul 28 '11 20:07

tillda


1 Answers

Good question.

We've had http://issues.apache.org/jira/browse/CASSANDRA-876 open for a while to add this, but nobody's bothered finishing it because

  1. CL.ONE is just fine for a LOT of workloads without any extra gymnastics
  2. Reads are so fast anyway that doing the extra one is not a big deal (and in fact Read Repair, which is on by default, means all the nodes get checked anyway, so the difference between CL.ONE and higher is really more about availability than performance)

That said, if you're motivated to help, ask on the ticket and I'll be happy to point you in the right direction.

like image 56
jbellis Avatar answered Oct 01 '22 19:10

jbellis