Join us at ScyllaDB LIVE, instructor-led NoSQL training sessions | June 18
Register now

Replication Strategy

4 min to complete

Replication Strategy

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

SimpleStrategy – Places the first replica on the node selected by the partitioner. The partitioner, or partition hash function, is a hash function for computing which data is stored on which node in the cluster. The 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 scylla-node2 nodetool status

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

docker exec -it scylla-node2 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.