1
votes

I was reading "Cassandra The Definitive Guide" and page 46 has this to say about Replication Factor:

"The replication factor essentially allows you to decide how much you want to pay in performance to gain more consistency. That is, your consistency level for reading and writing data is based on the replication factor"

Now to me that's news. If replication is increased, it is kind of intuitive that it improves availability and depending on topology of the cluster its partition tolerance as well. However why does the author say that it increases consistency. I will think its quite the opposite. You have to take extra effort to ensure consistent state of your persistent data by propagating updates to every replica on different nodes. So more the replica, harder it is to maintain consistency. Why does the author say the exact opposite?

All inputs appreciated.

2
To help readers understand the relationship more readily (at least this is my understanding). From the above quote Performance Sacrifice => Improved Consistency. This means Increased Replication => Improved Consistency since you can expect performance sacrifice only with increased replication. - Ace

2 Answers

0
votes

The consistency level specifies how many replicas must respond before a result is returned. See the documentation.

So, if you're using a consistency level of Quorum or higher, the higher the replication factor, the more nodes need to respond before a result can be returned.

0
votes

Replication factor describes how many copies of your data exist. Consistency level describes the behavior seen by the client. Perhaps there's a better way to categorize these.

As an example, you can have a replication factor of 2. When you write, two copies will always be stored, assuming enough nodes are up. When a node is down, writes for that node are stashed away and written when it comes back up, unless it's down long enough that Cassandra decides it's gone for good.

For example with 2 nodes, a replication factor of 1, read consistency = 1, and write consistency = 1:

Your reads are consistent You can survive the loss of no nodes. You are really reading from 1 node every time. You are really writing to 1 node every time. Each node holds 50% of your data.

For More Info: Configuring data consistency