cloudparts

Apache Cassandra

A masterless, wide-column database that spreads and replicates partitions around a ring of equal nodes, with consistency chosen per request.

Apache · Top-level project
Type
Open source
Foundation
The Apache Software Foundation, top-level project, joined January 2009
License
Apache 2.0
Facts checked
6 October 2026

What it is

A Cassandra cluster has no leader. Each node owns several ranges on a token ring (16 virtual nodes per node by default), and a row’s partition key is hashed to a token that decides which nodes hold its replicas; the replication factor is set per keyspace and per datacenter. Any node can coordinate a request. It sends a write to every replica and waits for as many answers as the consistency level asks for: ONE, QUORUM (a majority), LOCAL_QUORUM (a majority in this datacenter) or ALL. Nodes learn about each other by gossip. Conflicting writes resolve by timestamp, last write wins, and replicas catch up through hinted handoff, read repair and Merkle-tree anti-entropy repair.

On each node, a write is appended to the commit log and kept in a memtable, which is later flushed to immutable SSTables on disk; background compaction merges them. Deletes are tombstones that must outlive gc_grace_seconds (ten days by default), so repair has to run within that window. You define tables in CQL, a SQL-like language without joins, and design one table per query, choosing a partition key and clustering columns that keep each query’s rows together. The current release line is 5.0 (September 2024), which added Storage Attached Indexes, vector search, trie memtables and the Unified Compaction Strategy; 6.0 is in alpha. Cassandra is free under Apache 2.0; managed versions include Amazon Keyspaces, Azure Managed Instance for Apache Cassandra and Astra DB from DataStax, which IBM bought in 2025.

Why teams pick it

  • No master to fail over: every node can take reads and writes for any key
  • Replication across datacenters is built in, and LOCAL_QUORUM keeps each request inside one region
  • Append-only writes (commit log, memtable, SSTables) handle very high write rates
  • Grows by adding nodes, and virtual nodes spread the data that moves across many neighbours
  • Apache 2.0, with several managed services that speak the same CQL protocol

Watch out for

  • No joins and no cross-partition transactions: you design tables around known queries and often write the same data to several of them
  • Ongoing operational work: repair before tombstones expire, compaction tuning, JVM tuning and long, careful upgrades
  • Last-write-wins by timestamp depends on synchronised clocks, and lightweight transactions (IF NOT EXISTS) use Paxos and cost noticeably more
  • Materialized views are experimental and off by default; flexible indexing on non-key columns only arrived with SAI in 5.0
  • Managed versions behave differently: Amazon Keyspaces always writes at LOCAL_QUORUM and ignores compaction and other server settings

Good for

Data model
Wide rows: partitions of rows sorted by clustering columns
Query language
CQL, a SQL-like language without joins
Client protocol
CQL native protocol
Secondary indexes
Storage Attached Indexes (SAI) since 5.0
Transactions
Single-partition lightweight transactions (Paxos)
Consistency
Chosen per request: ONE, QUORUM, LOCAL_QUORUM, ALL
How it scales
Token ring, 16 virtual nodes per node by default
Replication
Leaderless; replication factor per keyspace and datacenter
Multi-region
Every datacenter takes writes; conflicts resolve by timestamp, last write wins
Storage engine
LSM: commit log, memtables, SSTables
Written in
Java
Ways to run it
Self-hosted, K8ssandra on Kubernetes, Amazon Keyspaces, Azure Managed Instance, Astra DB

The Apache Cassandra family

1 technologies built from or on Apache Cassandra

Alternatives

What all wide-column stores have in common →Compare side by side →

How it fits with other technologies

A table shaped for one query, written and read at LOCAL_QUORUM in cqlsh · sql

-- three replicas in each of two datacenters
CREATE KEYSPACE iot WITH replication =
  {'class': 'NetworkTopologyStrategy', 'eu-west': 3, 'us-east': 3};

-- query: latest readings for one sensor on one day
CREATE TABLE iot.readings_by_sensor_day (
  sensor_id   text,
  day         date,
  ts          timestamp,
  temperature double,
  PRIMARY KEY ((sensor_id, day), ts)
) WITH CLUSTERING ORDER BY (ts DESC);

CONSISTENCY LOCAL_QUORUM;  -- cqlsh: 2 of the 3 local replicas must answer

INSERT INTO iot.readings_by_sensor_day (sensor_id, day, ts, temperature)
VALUES ('s-17', '2026-10-06', '2026-10-06 09:30:00+0000', 21.4)
USING TTL 2592000;  -- expires after 30 days

SELECT ts, temperature FROM iot.readings_by_sensor_day
WHERE sensor_id = 's-17' AND day = '2026-10-06' LIMIT 10;

-- Cassandra 5.0: a Storage Attached Index on a non-key column
CREATE INDEX readings_temp_sai ON iot.readings_by_sensor_day (temperature) USING 'sai';

Cassandra or ScyllaDB?#

ScyllaDB rewrote Cassandra’s design in C++ and speaks the same CQL protocol, so the two are often weighed against each other. Where they differ, according to each project’s own docs and licence:

Apache CassandraScyllaDB
Written inJava, on the JVM (5.0 adds JDK 17; 6.0 defaults to generational ZGC on JDK 21)C++ on the Seastar framework, no JVM
Inside a nodeOne JVM process serving all of the node’s token rangesOne shard per CPU core: a thread pinned to that core with its own memory and data
Spreading dataVirtual nodes: each node owns 16 token ranges by defaultTablets by default: each table is split into tablets that split and move as data grows
APIsCQLCQL (Cassandra 3.11 level, with some 4.0 features) and the DynamoDB API, called Alternator
Recent featuresStorage Attached Indexes, vector search, trie memtables, Unified Compaction Strategy (5.0)Tablets; vector search, but only in ScyllaDB Cloud; no Storage Attached Indexes
LicenceApache 2.0Source-available: free use capped at 10 TB and 50 vCPUs, no SaaS; the AGPL edition ended with 6.2
ManagedAmazon Keyspaces, Azure Managed Instance, Astra DB (IBM)ScyllaDB Cloud, billed by instance rather than per request
  • ScyllaDB works with Cassandra drivers and can import Cassandra’s SSTables, but check features such as user-defined functions, triggers and SAI before migrating: its compatibility page lists them as unsupported.

Where to run it#

Self-managed

Apache 2.0

Packages, tarballs or containers on your own machines. You own repair schedules, upgrades and capacity. On Kubernetes, the K8ssandra operator deploys and manages clusters.

Amazon Keyspaces

serverless, per request

A Cassandra-compatible service with no nodes to manage. Data is kept three times across Availability Zones; writes always use LOCAL_QUORUM, reads LOCAL_ONE or LOCAL_QUORUM. On-demand bills a read request unit per 4 KB read at LOCAL_QUORUM (half at LOCAL_ONE) and a write unit per 1 KB written; provisioned capacity is the alternative. Compaction, caching and similar settings are ignored.

Azure Managed Instance for Apache Cassandra

VMs in your network

Real open-source Cassandra, up to 5.0, deployed as virtual machine scale sets in your virtual network. Datacenters can join an existing ring on premises. Billed for the VMs and disks you choose, with no licence fee.

Astra DB

IBM since 2025

DataStax’s Cassandra-based cloud database with vector search. IBM announced it would buy DataStax in February 2025 and closed the deal in the second quarter of 2025; Astra DB is now sold as part of IBM watsonx.

Compaction strategies: STCS, LCS, TWCS or UCS?#

Compaction merges a table’s SSTables in the background, and each table picks a strategy with its compaction option. The strategy decides how many SSTables a read has to check, how many times each row is rewritten, and how much spare disk the node needs.

SizeTieredCompactionStrategy (STCS)LeveledCompactionStrategy (LCS)TimeWindowCompactionStrategy (TWCS)UnifiedCompactionStrategy (UCS)
How it groups SSTablesInto buckets of similar size (within 50–150% of the bucket’s average); a bucket is merged once it holds 4 SSTables (min_threshold)Flushes land in L0; from L1 down, each level is 10 times larger than the one above and holds non-overlapping SSTables of 160 MBInto time windows (one day by default) by each SSTable’s newest timestamp. STCS runs inside the current window; when it closes, the window is merged into one SSTable and never compacted againInto levels by density (size per share of the token range), split into shards at fixed token boundaries so compactions run in parallel. One setting, scaling_parameters, makes it tiered (T4, the default) or leveled (L10)
Read amplificationHigh: versions of one row can be spread over many SSTablesLow: a row is in at most one SSTable per level, plus L0Low for recent ranges: a query reads only the windows it coversTunable: L values read like LCS, T values like STCS; T8 for time series means more SSTables per read
Write amplificationLow: data is rewritten about once per size tierHigh: data is rewritten at each level, with more disk I/O and CPU than STCSLow: rows are compacted only inside their own windowTunable, the mirror image of reads: tiered writes less, leveled more
Space overheadLarge: merging the biggest bucket needs room for the old and new SSTables at once, and tombstones in big SSTables wait for a rare big mergeAbout 10% of the dataSmall when data has a TTL: an SSTable whose rows have all expired is dropped wholeLow, per the 5.0 release notes: compactions are split into shards (1 GiB target SSTables) that run in parallel
Best forWrite-intensive tablesRead-heavy tables, and rows that are updated or deleted oftenImmutable, time-ordered data written with a TTL; aim for 20–30 windows, such as 3-day windows for a 90-day TTLNew tables of any kind on 5.0, including time series with TTLs (T8, or T4 for faster reads)
Avoid whenReads must be fast, or the same rows are updated and deleted oftenWrites dominate, or the data is immutable time seriesRows are updated or deleted across windows, TTL and non-TTL data share a table, or writes carry old timestampsSome nodes still run 4.x, which has no UCS; Amazon Keyspaces ignores compaction settings
Status in 5.0Still the default when a table names no strategy (default_compaction in cassandra.yaml)Legacy: the docs point new tables to UCSStill documented as the strategy for time series and TTL dataNew in 5.0 and recommended by the docs; the default only in cassandra_latest.yaml, as T4
  • The 5.0 docs pull in two directions on time series: the UCS page recommends UCS for most workloads “whether read-heavy, write-heavy, mixed read-write, or time-series”, while the TWCS page still calls TWCS the recommended strategy for time series and TTL data. Switching between STCS, LCS and TWCS rewrites the data with a full compaction; UCS can change its scaling parameter in flight.
  • ScyllaDB’s docs list STCS, LCS, TWCS and its own Incremental Compaction Strategy (ICS); UCS is not among them.

Modelling time series#

Cassandra fits time series whose questions are per series: one sensor’s readings over a time range, or its latest value. Put the series and a time bucket in the partition key, such as (sensor_id, day), and the timestamp in a clustering column sorted newest first. Each partition then holds one sensor’s day in time order, and a week means reading seven partitions. The bucket keeps partitions bounded: without it a sensor’s partition grows forever, toward Cassandra’s hard limit of 2 billion cells per partition and into trouble long before it. The docs size partitions by counting cells, with about 8 bytes of overhead per cell, and suggest bucketing coarser (by month, say) when per-day partitions come out too small. Declare CLUSTERING ORDER BY (ts DESC) when most reads want the newest rows: reverse-order reads are slower, and the order can’t be changed once the table exists.

Expiry is where compaction matters. Give every row a TTL, or set default_time_to_live on the table, and use TWCS with a window that splits the TTL into 20–30 windows. Each closed window becomes one SSTable whose rows all expire at about the same time, so Cassandra deletes the file instead of compacting tombstones away. What Cassandra doesn’t do is roll data up. GROUP BY works only on primary key columns, and a filter across all partitions needs ALLOW FILTERING, which scans the whole table, so an hourly average across every sensor usually comes from a second table the application writes, or from a Spark job.

The table from the snippet, set up to expire by window#

Same partition key and clustering order, plus a table-wide TTL, one-day TWCS windows and read repair turned off, so that reads of old days don’t copy their rows into today’s SSTable.

sql
CREATE TABLE iot.readings_by_sensor_day (
  sensor_id   text,
  day         date,
  ts          timestamp,
  temperature double,
  PRIMARY KEY ((sensor_id, day), ts)
) WITH CLUSTERING ORDER BY (ts DESC)
  AND default_time_to_live = 2592000           -- every row expires 30 days after it is written
  AND compaction = {
    'class': 'TimeWindowCompactionStrategy',
    'compaction_window_unit': 'DAYS',
    'compaction_window_size': '1'               -- 30 one-day windows over the TTL
  }
  AND read_repair = 'NONE';                     -- the coordinator reconciles replicas but writes nothing back

-- Cassandra 5.0 alternative:
-- compaction = {'class': 'UnifiedCompactionStrategy', 'scaling_parameters': 'T8'}

-- latest reading for one sensor
SELECT ts, temperature FROM iot.readings_by_sensor_day
WHERE sensor_id = 's-17' AND day = '2026-10-24' LIMIT 1;

-- one hour of one sensor’s day
SELECT ts, temperature FROM iot.readings_by_sensor_day
WHERE sensor_id = 's-17' AND day = '2026-10-24'
  AND ts >= '2026-10-24 08:00:00+0000' AND ts < '2026-10-24 09:00:00+0000';

What keeps expired SSTables on disk#

TWCS saves work only if every row in an SSTable expires around the same time. These are the usual reasons it doesn’t.

TTL and non-TTL data in one table

file never expires

An SSTable is dropped only when everything in it has expired, so one row without a TTL, or with a much longer one, keeps the whole file. The compaction docs warn that mixed TTLs make tombstones harder to drop. Keep data with different lifetimes in different tables.

Updates and deletes across windows

windows never merge

TWCS never compacts two windows together, so a delete or overwrite written today can’t remove a row in last week’s SSTable; both stay until they expire. The Last Pickle recommends TWCS only for immutable rows written with a TTL.

Old rows in new windows

read repair, hints, `USING TIMESTAMP`

A window is chosen by an SSTable’s newest timestamp. Read repair writes old rows into today’s memtable, which flushes them into today’s SSTable, and that file then lives until its oldest rows and newest rows have both expired. The Last Pickle notes that hints and repair can mix data the same way and advises turning read repair off on TWCS tables; the Cassandra docs say to avoid USING TIMESTAMP and to run repairs often, since repair streams data without mixing it.

Tombstones and blockers

`gc_grace_seconds`

Expired rows become tombstones that stay for at least gc_grace_seconds (ten days by default), and a fully expired SSTable is kept while an older SSTable holds data it might shadow. sstableexpiredblockers lists the files in the way. The unsafe_aggressive_sstable_expiration option skips that check, at the risk of deleted data coming back.

See it in a real stack

No architecture uses Apache Cassandra yet. Drop it into the playground and wire it up yourself.Open playground →

Benchmarks

How to read a benchmark →
Where it came from2007–2025

Facebook’s Inbox Search had to store an index of the messages every user sent and received: billions of writes a day, served from data centers on both US coasts. Avinash Lakshman, one of the authors of Amazon’s 2007 Dynamo paper, and Prashant Malik built Cassandra for it. They combined Dynamo’s way of spreading and replicating data, with consistent hashing, gossip and no master, with the column families and log-structured storage of Google’s Bigtable. Inbox Search launched on it in June 2008 for about 100 million users.

Facebook open-sourced Cassandra in 2008. It entered the Apache Incubator in January 2009 and became a top-level project in February 2010. That November, Facebook chose HBase rather than Cassandra for its new Messages system, finding Cassandra’s eventual consistency hard to reconcile with it, but development carried on at Apache.

Version 4.0 arrived in July 2021, six years after 3.0, after the project built new tools to test correctness at scale. 5.0, in September 2024, added Storage Attached Indexes and vector search.

Why it’s built this way

No master: every node is equal
Running on hundreds of machines across data centers, components fail all the time. With no single point of failure, any node can take any request and a lost node needs no failover.
Consistency chosen per request
Cassandra adapted Dynamo’s rule that reads and writes must overlap (R + W > N) into named levels such as ONE and QUORUM, so each query can trade freshness for latency and availability.
Bigtable’s log-structured storage
Inbox Search needed very high write throughput. Appending to a commit log and an in-memory table, then flushing sorted files and compacting them later, means a write never waits for a read.

Timeline

  1. 2007

    Amazon’s Dynamo paper, co-written by Avinash Lakshman, is published

  2. 2008

    Facebook launches Inbox Search on Cassandra and open-sources it

  3. 2009

    Cassandra enters the Apache Incubator in January

  4. 2010

    Becomes a top-level Apache project; Facebook picks HBase for Messages

  5. 2011

    Cassandra 1.0 is released in October

  6. 2021

    Cassandra 4.0 ships in July, six years after 3.0

  7. 2024

    Cassandra 5.0 adds Storage Attached Indexes and vector search

  8. 2025

    IBM acquires DataStax, maker of Astra DB

Sources43 · facts checked 6 October 2026

Improve this page on GitHub