Replication Strategy

Replication Strategy

4 min to complete

The Replication Strategy determines which nodes replicas are placed.  There are two available replication strategies:

SimpleStrategy – Places the first replica on the node selected by the partitioner. Remaining replicas are placed in the clockwise direction on the node ring. This replication strategy should not be used in production environments. 

Network Topology Strategy – Places replicas in a clockwise direction in the ring until it reaches the first node of a different rack. This is used for clusters deployed across multiple data centers. Using this strategy allows you to define the number of replicas for each DC.

As an example, if we have two DCs, DC1 with a replication factor of 3 and DC2 with a replication factor of 2, the replication factor of the Keyspace will be 5. Let’s see how to create such a keyspace.

You can find more info about which replication strategy should be used here.

Hands-on: Create a keyspace on a multi DC cluster

Using the multi DC cluster we previously created, we will create a new keyspace, this time with the Network Topology Strategy, and replication of  (‘DC1’: 3, ‘DC2’: 2).

First, make sure all nodes are up:

docker exec -it mms_scylla-node2_1 nodetool status

Next create the Keyspace, with the Network Topology Strategy, and replication of  (‘DC1’: 3, ‘DC2’: 2):

docker exec -it mms_scylla-node2_1 cqlsh
CREATE KEYSPACE scyllaU WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'DC1' : 3, 'DC2' : 2};

Let’s make sure the Keyspace was created:

Use scyllaU;

We can see that indeed the Keyspace was created with the defined replication factor of 3 for DC1 and 2 for DC2.

To report this post you need to login first.