DS201 Study Notes: Cassandra Replication

DS201 course study notes on Cassandra replication: replication factor settings and strategies (SimpleStrategy, NetworkTopologyStrategy).

Study notes from DS201: Foundations of Apache Cassandra™ and DataStax Enterprise.

What is Replication?

Cassandra employs replication to achieve high availability and fault tolerance by copying data to multiple nodes. This prevents data loss and service interruptions even when some nodes experience failures, enabling continuous operation.

Replication Factor (RF)

The Replication Factor (RF) is a parameter that specifies how many times each dataset is replicated within the cluster. The RF value can be set for the entire cluster or for specific keyspaces.

  • RF = 1: Data is stored on only one node. There is a risk of data loss if the node fails.
  • RF = 2: Data is replicated to two nodes. Data remains available even if one node goes down.
  • RF = 3: Data is replicated to three nodes. Data remains available even if two nodes go down.

Increasing the RF value improves fault tolerance, but also increases storage usage and write overhead. It is important to set an appropriate RF based on the system’s requirements (availability, durability, performance).

Replication Strategy

Cassandra has several replication strategies that determine how data is replicated.

  • SimpleStrategy: Designed for clusters with a single data center. Distributes and replicates data evenly across nodes in the cluster.
  • NetworkTopologyStrategy: Designed for clusters with multiple data centers and racks. Replicates data considering the data center and rack topology, improving fault tolerance in geographically distributed environments. This strategy is typically recommended for production environments.

The combination of replication strategy and RF determines data placement and fault tolerance in a Cassandra cluster.