Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Say we have three nodes(simple replica no sharding) i.e. N1,N2 and N3 with replication factor as 3.

As read and write request can go to any node, Say Request write request(to update the same record at same time) comes and goes
node N1.

Read request comes to read the same document and goes to node N2. I believe it will return stale data as write is not replicated to N2 yet ?
Consider the default configuration where i have not tuned the read and write concerns.

I believe problem in step2 can be resolved with either of below options

a. In synch replication, Good for strong consistency but bad for performance

2 Answers
2

Mostly yes, but with small correction. You can get the stale data if they aren't replicated yet to another node (replication happens almost at the same time, but still could be delayed because of garbage collection, etc.). You can get strong consistency by tuning consistency levels...

The comment is about point 3c - Cassandra's partitions are replicated to all nodes that were selected as replicas for particular partition - the driver or coordinator node can come to any of them, depending on multiple factors. There is no such thing as an additional sharding key that will route to specific node - all replica nodes are equal.

You said There is no such thing as an additional sharding key that will route to specific node - all replica nodes are equal. Consider the case of ecommerce application. I believe this is possible in cassandra(like in mongo), For a particular category like Mobile phone,you can send read and write request to particular node(say N1) in cluster instead of sending to all node ? Now further whatever replicas N1 is assigned to, those nodes will also receive those requests.
– user3198603Jun 21 '18 at 1:38

No. The language drivers are smart enough to avoid going to coordination node and reaching directly one of the replica nodes, so at least for one node, read or write is performed locally.
– Alex OttJun 23 '18 at 8:06

Ok looks like it meant driver installed at client side which knows upfront which node it will find record based on token value/load/responsiveness ?
– user3198603Jun 23 '18 at 8:09

You cannot accomplish 3a (in sync replication) because Cassandra doesn't do that. You can use the write consistency ALL (as you mention in 3b) which will eagerly attempt to write to all replicas. Even if the write says it fails it still may have worked (just the nodes didn't respond in time).

About point 2, you mentioned you haven't tuned read and write consistencies, but depending on the driver you use there may be different default consistencies so it's impossible to say if it's correct. I made a table below describing the scenarios. This table assumes the write query responded with a success.