NetworkTopologyStrategy replicates keyspace data with awareness of datacenters and racks. It lets each datacenter have its own replication factor, making it suitable for production clusters where failure domains matter. section 5.2.2 section 5.4
For each partition, the strategy:
- Uses the configured replication factor separately for each selected datacenter. section 5.2.2
- Selects replicas on different racks within a datacenter whenever possible. section 5.2.2
- Continues selecting nodes in the same datacenter after every rack has already contributed a replica. section 5.2.2
- Handles multiple datacenters independently, rather than placing replicas solely on the next nodes around the ring. section 5.2.1 section 5.2.2
Creating a reviews keyspace
A keyspace replicated three ways in datacenter1 can be created with: CREATE KEYSPACE reviews WITH replication = {'class': 'NetworkTopologyStrategy', 'datacenter1': '3'};. With three racks represented in a datacenter, this arrangement can tolerate losing an entire rack; suitable consistency levels can also support continued service after a datacenter failure. section 5.2.2
