Replication Strategy

5 min reading

The Replication Strategy determines on which nodes replicas are placed. There are two available replication strategies: SimpleStrategy - A legacy strategy that ignores racks and datacenters. It isn’t supported for keyspaces that use tablets , the default in newer versions of ScyllaDB, and it should not be used in production environments. Network Topology Strategy - Places the replicas of each piece of data on nodes in different racks where possible. This is used for clusters deployed across multiple data centers. Using this strategy allows you to define the number of replicas for each DC. It’s the recommended strategy, and the only one that tablets support. As an example, if we have two DCs, DC1 with a replication factor of 3 and DC2 with a replication factor of 2, the Keyspace will store five copies of each row in total. 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:

bash
docker exec -it scylla-node2 nodetool status

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

bash
docker exec -it scylla-node2 cqlsh
cql
CREATE KEYSPACE scyllaU WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'DC1' : 3, 'DC2' : 2};

Let’s make sure the Keyspace was created:

cql
Use scyllaU;
cql
DESCRIBE KEYSPACE

We can see that, indeed, the Keyspace was created with the defined replication factor of 3 for DC1 and 2 for DC2, and that it uses tablets (tablets = {'enabled': true}). You may also see two warnings: the keyspace isn’t RF-rack-valid (each datacenter in this lab has a single rack), and a replication factor of 2 in DC2 is lower than the recommended 3. Both are fine for this lab.


Something wrong with this lesson? Tell us