Learn Apache Cassandra

Masterless wide-column database for huge write volumes and always-on availability

18 lessons · 3 hours · 4 levels · covers Apache Cassandra 5.0

Apache Cassandra is a distributed, masterless wide-column database designed to stay available across machines and data centers with no single point of failure. You model tables around your queries in CQL, an SQL-like language, and it scales linearly by adding nodes. It is used for time-series, messaging, IoT and other high-write workloads at very large scale.

Before you start

Apache Cassandra builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics6 lessons · 1 hour in total
2. PracticalUse it productively at work, with the usual idioms12 lessons · 2 hours in total
3. AdvancedThe less common features, performance and trade-offs15 lessons · 3 hours in total
4. ExpertInternals and the edge cases experts know18 lessons · 3 hours in total

The Apache Cassandra tree

Apache CassandraWhat Cassandra is: a masterless ringWhat Cassandra is: amasterless ringcqlsh and keyspacescqlsh and keyspacesTables, partition keys and clustering columnsTables, partition keysand clustering colu…Data types, collections and UDTsData types,collections and UDTsINSERT and SELECT with key restrictionsINSERT and SELECTwith key restrictionsUpserts, updates and deletesUpserts, updates anddeletesClustering order and range queriesClustering order andrange queriesQuery-first modeling and denormalizationQuery-first modelingand denormalizationTTL and write timestampsTTL and writetimestampsTunable consistencyTunable consistencyBatches: what they are and are notBatches: what theyare and are notDrivers, prepared statements and pagingDrivers, preparedstatements and pag…Creating and altering tablesCreating and alteringtablesSELECT: reading dataSELECT: reading dataInner joinsInner joinsTransactions and ACIDTransactions andACID
Essentials and Practical shown (12 of 18 lessons); the full list is below. Click a lesson to read it.

All 18 lessons, in order

Architecture and setup

  1. What Cassandra is: a masterless ring · Essentials · 9 min

    Cassandra spreads partitions of data over a ring of equal nodes and replicates each partition to several of them.

  2. cqlsh and keyspaces · Essentials · 8 min

    Connect with cqlsh and create keyspaces that define replication strategy and factor per data center.

CQL tables and queries

  1. Tables, partition keys and clustering columns · Essentials · 12 min

    Define a primary key as a partition key that distributes data plus clustering columns that sort rows inside a partition.

  2. Data types, collections and UDTs · Essentials · 10 min

    Use CQL types like uuid, timeuuid, timestamp and decimal, collections (list, set, map), user-defined types and vectors.

  3. INSERT and SELECT with key restrictions · Essentials · 12 min

    Write rows with INSERT and read them with SELECT, respecting the rules on which key columns a WHERE clause may filter.

  4. Upserts, updates and deletes · Essentials · 10 min

    Learn that INSERT and UPDATE are both upserts, that deletes write tombstones, and how last-write-wins resolves conflicts.

Query-first data modeling

  1. Clustering order and range queries · Practical · 10 min

    Use clustering columns and CLUSTERING ORDER BY to serve latest-first and time-range queries straight from disk order.

  2. Query-first modeling and denormalization · Practical · 14 min

    Design one table per query, duplicating data across tables, instead of normalizing and joining.

  3. TTL and write timestamps · Practical · 9 min

    Expire data automatically with USING TTL or a table default, and inspect cell timestamps and remaining TTLs.

  4. Storage-attached indexes (SAI) · Advanced · 12 min

    Query non-key columns with SAI indexes in Cassandra 5.0, including range and vector search, and know when an index is the wrong tool.

  5. Partition sizing, bucketing and hot spots · Advanced · 12 min

    Keep partitions bounded with time or hash buckets, and estimate partition size before a table goes to production.

Consistency and transactions

  1. Tunable consistency · Practical · 13 min

    Choose consistency levels like ONE, QUORUM and LOCAL_QUORUM per request and reason about R + W > RF.

  2. Batches: what they are and are not · Practical · 10 min

    Use logged batches to keep denormalized tables in sync, and avoid batches as a bulk-loading tool.

  3. Drivers, prepared statements and paging · Practical · 11 min

    Connect from code with a driver, use prepared statements, token-aware routing, async queries and automatic paging.

  4. Lightweight transactions (compare-and-set) · Advanced · 12 min

    Use IF NOT EXISTS and IF conditions for linearizable compare-and-set on a single partition, and understand their cost.

Storage and cluster internals

  1. Storage engine: commit log, memtables, SSTables · Expert · 14 min

    Follow writes through the commit log and memtable to immutable SSTables, and reads through bloom filters, indexes and compaction.

  2. Tombstones, gc_grace and repair · Expert · 14 min

    Understand how tombstones affect reads, why repair must run within gc_grace_seconds, and how to avoid resurrected data.

  3. Token ring, vnodes, gossip and snitches · Expert · 13 min

    Understand how nodes own token ranges via vnodes, discover each other through gossip, and place replicas with snitches.