Skip to content

AxonOps — AI-Native Control Plane for Open Source Data Platforms

Cassandra Architecture

Cassandra’s architecture explains its behavior. The partition key determines which node stores data—get it wrong, and queries become slow or impossible. Deletes write tombstones instead of removing data immediately—ignore this, and deleted records can reappear. Nodes can disagree on data temporarily—while repair is the primary mechanism for full convergence, hinted handoff and read repair also help synchronize replicas.

The design combines Amazon Dynamo’s distribution approach (masterless ring, gossip protocol, tunable consistency) with Google BigTable’s storage approach (LSM-tree, SSTables, memtables). Understanding both sides leads to better decisions about data modeling and operations.

Apache Cassandra is a distributed, peer-to-peer database designed for:

  • High Availability: No single point of failure
  • Scalability: Add nodes to increase capacity (actual scaling depends on workload and data model)
  • Geographic Distribution: Multi-datacenter replication
  • Tunable Consistency: Balance between consistency and availability
CassandraCluster N1 Node 1 N2 Node 2 N1->N2 N3 Node 3 N1->N3 N4 Node 4 N1->N4 N5 Node 5 N1->N5 N6 Node 6 N1->N6 N2->N3 N2->N4 N2->N5 N2->N6 N3->N4 N3->N5 N3->N6 N4->N5 N4->N6 N5->N6 gossip Gossip Protocol (Peer-to-Peer Communication)

Cassandra organizes nodes in a logical ring structure using consistent hashing:

  1. Each node owns a range of tokens on the ring
  2. Data is assigned to nodes based on partition key hash
  3. Data is replicated to multiple nodes for fault tolerance

The partitioner is responsible for computing a hash (token) value from the partition key. Cassandra uses this hash to determine data placement on both write and read operations:

  • Murmur3Partitioner (default): Uses the MurmurHash3 algorithm, producing a 64-bit hash value. Token range spans from -2^63 to 2^63-1.
  • RandomPartitioner: Uses MD5 hashing, producing a 128-bit hash. Token range spans from 0 to 2^127-1.

Write operations: When inserting data, the coordinator node computes hash(partition_key) to produce a token value. This token maps to a specific position on the ring, identifying the primary replica node. Additional replicas are selected by traversing the ring clockwise.

Read operations: The same hash calculation occurs during SELECT queries. The coordinator computes hash(partition_key) from the WHERE clause to locate the exact nodes holding the requested data.

This deterministic hashing ensures that:

  • The same partition key always maps to the same token
  • Any node can calculate which nodes own a given partition
  • No central directory or lookup service is required
TokenRing Token Ring (Consistent Hashing) Simplified: actual range is -2^63 to 2^63-1 A Node A Tokens: 0-25 B Node B Tokens: 26-50 A->B C Node C Tokens: 51-75 B->C D Node D Tokens: 76-100 C->D D->A

The partition key determines which node stores the data:

CREATE TABLE users (
user_id UUID, -- Partition key
name TEXT,
email TEXT,
PRIMARY KEY (user_id)
);

How it works:

  1. Partition key value is hashed: hash(user_id) → token
  2. Token maps to a token range
  3. Node owning that range stores the data

Data is replicated across multiple nodes for fault tolerance:

CREATE KEYSPACE my_app WITH replication = {
'class': 'NetworkTopologyStrategy',
'dc1': 3, -- 3 copies in dc1
'dc2': 3 -- 3 copies in dc2
};

Replication Factor (RF): Number of copies across the cluster.


  • JVM - Java Virtual Machine configuration and garbage collection
  • Cassandra Memory - Heap, off-heap, and page cache
  • Linux - Kernel settings, swap, THP, and NUMA
  • Compaction Overview - Compaction overview
  • STCS - Size-Tiered Compaction Strategy
  • LCS - Leveled Compaction Strategy
  • TWCS - Time-Window Compaction Strategy
  • UCS - Unified Compaction Strategy (5.0+)

Write path from client through commit log and memtable to SSTableWrite path from client through commit log and memtable to SSTableClient WriteRequestCoordinatorNode(any node)Commit Log(durability)Memtable(in-memory)SSTable(on disk)when full
  1. Commit Log: Write-ahead log for durability
  2. Memtable: In-memory sorted structure
  3. SSTable: Immutable on-disk file (created when memtable flushes)
Read path: coordinator issuing parallel replica readsRead path: coordinator issuing parallel replica readsClient Read RequestCoordinator NodeNode 1Node 2parallel read
SSTable Files:
├── data.db # Actual data
├── index.db # Partition index
├── filter.db # Bloom filter
├── summary.db # Index summary
├── statistics.db # Table statistics
├── compression.db # Compression info
└── toc.txt # Table of contents

Cassandra offers tunable consistency per operation:

LevelReadsWrites
ONE1 replica1 replica
QUORUMRF/2 + 1RF/2 + 1
LOCAL_QUORUMQuorum in local DCQuorum in local DC
ALLAll replicasAll replicas

For strong consistency (read-your-writes):

R + W > RF
Where:
R = Read consistency level (number of replicas)
W = Write consistency level (number of replicas)
RF = Replication factor

Example with RF=3:

  • QUORUM reads (2) + QUORUM writes (2) = 4 > 3 ✓
  • ONE reads (1) + ONE writes (1) = 2 < 3 ✗

By storing multiple copies of data across nodes, Cassandra tolerates node failures without loss of service or data. As described in the Consistency Model section, operations succeed as long as enough replicas respond to satisfy the consistency level—allowing nodes, racks, or entire datacenters to fail while maintaining availability.

For details on how Cassandra detects failures and synchronizes replicas after recovery, see Replica Synchronization.

NetworkTopologyStrategy enables per-datacenter replication:

CREATE KEYSPACE production WITH replication = {
'class': 'NetworkTopologyStrategy',
'us-east': 3,
'eu-west': 3
};
MultiDC cluster_dc1 Datacenter 1 (RF=3) cluster_dc2 Datacenter 2 (RF=3) A1 N1 A2 N2 A1--A2 A3 N3 A2--A3 A4 N4 A3--A4 A5 N5 A4--A5 A6 N6 A5--A6 A7 N7 A6--A7 A8 N8 A7--A8 A9 N9 A8--A9 A9--A1 B1 N1 B2 N2 B1--B2 B3 N3 B2--B3 B4 N4 B3--B4 B5 N5 B4--B5 B6 N6 B5--B6 B7 N7 B6--B7 B8 N8 B7--B8 B9 N9 B8--B9 B9--B1 cluster_dc1 cluster_dc1 cluster_dc2 cluster_dc2 cluster_dc1--cluster_dc2 Replication

With LOCAL_QUORUM, each datacenter operates independently—surviving node failures, network partitions, or complete datacenter outages without losing availability or data.


FactorImpact
Commit log syncperiodic (default) vs batch
Memtable sizeLarger = fewer flushes
CompactionBackground CPU/IO
ReplicationMore replicas = more writes
FactorImpact
Partition sizeSmaller is better
SSTable countFewer is better
Bloom filtersReduce disk reads
CachingKey/row cache hit rate
Data modelQuery-driven design