educative.io

Does it help to do R=3 when W=1?

In this section, this was mentioned below. But when we only write to 1 node, why would we read from multiple nodes? There should be no other nodes that have this data (except for replicas, but replicas at most have the most recent data as well)

For faster writes, we can use R=3, W=1

Similar question applies to the statement about making faster reads.

W=1 means we waited for confirmation from one node; the data is still getting replicated to all the replica nodes.

When we read, we have to read from three nodes to meet quorum requirements. We don’t know if the data has been replicated to other nodes yet and if we read from “less than three” nodes, we might end up reading from nodes where the data has not been replicated. This is a typical “quorum” scenario and is extensively used in distributed systems.

1 Like

Thanks. When you said “data still getting replicated to all nodes”, does the data get replicated to all nodes in the cluster or all nodes that are responsible for that particular partition (in this case, it would be one node, and its replicas)?
Also, as mentioned in the original question, wouldn’t the replicas at most have the latest data as the initial node that took the write request? If the initial write request didn’t go through the node, no other nodes (write node or its replicas) would have any newer data, right? Even with hinted handoff, we still need that particular designated node (since W=1) to process the write request before that write result can be replicated.

Yes, it means the data is getting replicated to all the replica nodes (and not all the nodes in the system). Each piece of data only gets stored on a fixed number of nodes (which is equal to the replication factor).

Also, yes, the replicas will have “at most” the latest data, but we are not sure if the replication process has finished or not. Meaning if the data has been completely replicated to all the replicas yet. That is why we need to read from many nodes (in this case 3) to confirm that.

Your statement regarding hinted handoff is not completely right. Although the write could fail on the first node (or the coordinator could be down), but the replicas can still take the request. As mentioned in the “replication” lesson:

If a client cannot contact the coordinator node, it sends the request to a node holding a replica.

In short, W=1 means we need confirmation from any one node.

In Dynamo’s case, this gets even more interesting, because with Sloppy Quorum, the original replica nodes could all fail and Dynamo will store hints for each failed write. The client will not see the data until one of the replica nodes comes online again and the hinted handoff gets applied successfully.

We would suggest going through Cassandra’s replication process too, as it does not use Sloppy Quorum.

1 Like

Thanks a lot!