In this scenario, you will:
- Understand the differences between consistency vs. replication factor.
- Understand the differences of consistency on a write vs. a read.
One of the challenges of distributed systems like Apache Cassandra™, is how to keep the data replicas consistent. Maintaining consistency requires balancing availability and partitioning. Fortunately, Cassandra lets you tune this balancing to your needs.
In this scenario we will tinker with consistency levels using operations that read and write.
We've already started up a three-node Cassandra cluster for you.
Let's ensure that all three nodes are up
Then start cqlsh:
(load schema and data)
Now check the current consistency level by executing the CONSISTENCY command as we have it written out for you here:
Notice that consistency is ONE; meaning only one node must acknowledge a write on a write request, and only one node must return a result set to satisfy a read request.
Set your consistency level to TWO by executing the following command:
NOTE: In this case, TWO is the same as ALL because our current replication settings store one replica per data center, and we have two data centers.
Retrieve the cassandra partition from the videos_by_tag table by executing the following command:
SELECT * FROM videos_by_tag WHERE tag = 'cassandra';
The query succeeds.