Apache Cassandra: Query-First Modeling and Tunable Consistency
A masterless ring where you design one table per query, choose your consistency per statement, and the tombstone is the thing that will surprise you.
Cassandra is a masterless, linearly scalable, multi-datacentre database that keeps writing when nodes fail - and it achieves that by giving up almost everything a relational database gives you. There are no joins, no foreign keys, no aggregations worth the name, no `ORDER BY` on arbitrary columns, no transactions across partitions, and no way to filter on a column you did not plan for. What you get instead is a write path that is close to the theoretical minimum cost, a read path that is predictable when the data model is right, and an architecture where every node is identical and losing one is uneventful.
Overview
Two things carry the operational half of the course. **Tunable consistency**: every statement names a consistency level, and `R + W > RF` is the arithmetic that decides whether you get strong consistency - which means consistency is a per-query engineering decision rather than a property of the database. And the **LSM storage engine**, which makes writes cheap by never updating in place and hands you **tombstones** in exchange: deletes are written as markers, they accumulate, they are returned to the read path until compaction removes them, and a query that reads a hundred thousand tombstones to return nothing is the characteristic Cassandra incident.
Seven modules, about 95 hours. The capstone is a global event feed with time-bucketed partitions and consistency and failure experiments.
Introduction
For a sandbox, a **three-node cluster** - not one node - because consistency levels, replication and repair simply do not exist on a single node, and discovering that in Module 3 means redoing Module 1. Docker Compose with `cassandra:5` is the quickest route. **`ccm`** (Cassandra Cluster Manager) is excellent for running several nodes and multiple datacentres on one machine. Note that Cassandra wants memory: 2 GB of heap per node minimum, so a three-node cluster on a laptop needs care and a four-node one usually needs a bigger machine.
Use **`cqlsh`** throughout, and get into the habit of `TRACING ON` - Cassandra's tracing shows you the coordinator, the replicas contacted, the SSTables read and the tombstones scanned, which is the most instructive diagnostic in the system.
One framing to carry through. In a relational database, the data model is the truth and queries are views over it. In Cassandra, **the queries are the specification and the data model is derived from them**. If you do not know the queries, you cannot design the schema - and a query that was not anticipated usually means a new table and a backfill, not a new `WHERE` clause.
What you will be able to do
- Explain the ring, token ranges, the coordinator and virtual nodes
- Use CQL fluently, and name precisely where it differs from SQL
- Design partition and clustering keys, and bound partition size deliberately
- Apply query-first modelling: enumerate queries, then build one table per query
- Denormalise correctly, and maintain the copies you create
- Use collections, UDTs and TTL, and state the cost of each
- Choose a consistency level per statement, and apply the R + W > RF arithmetic
- Explain last-write-wins conflict resolution and the risk of clock skew
- Use lightweight transactions, and state what they cost
- Explain why a multi-partition batch is usually a mistake
- Configure driver retry, speculative execution and token-aware routing
- Explain LSM storage, SSTables and the read path
- Choose a compaction strategy with a reason
- Diagnose tombstones, and explain why a queue is an anti-pattern
- Read a trace and act on what it shows
- Configure replication across racks and datacentres
- Run repair, understand hinted handoff, and replace a node
- Implement authentication, authorisation and TLS
- Produce a deployment, capacity and cost checklist
What each level covers
5 levels · 7 lessons
-
Beginner - Foundations
The ring and CQL; then the query-first discipline that is the whole of Cassandra data modelling.
2 lessons 17 min of reading
Start with The Ring, CQL, Keyspaces and Key Design → -
Intermediate - Application Behaviour
Consistency as a per-statement choice, last-write-wins, and the driver behaviour that decides what your users see.
1 lesson 7 min of reading
Start with Consistency Levels, Timestamps, LWT and Batches → -
Advanced - Performance and Reliability
The LSM engine, compaction and the tombstone; then replication, repair and node replacement.
2 lessons 18 min of reading
Start with LSM Storage, Compaction, Tombstones and Tracing → -
Expert - Security and Production Architecture
Roles and TLS, the metrics that matter, capacity planning and the rolling upgrade.
1 lesson 10 min of reading
Start with Authentication, Authorisation, TLS and Operations → -
Capstone
One global event feed, defended on bounded partitions, measured consistency and a survived node loss.
1 lesson 7 min of reading
Start with Capstone - Global Event Feed →
Guides and articles
Longer reading about this subject, written alongside the course.
Before you start
- Apache Cassandra 5 or later, as a three-node cluster
- cqlsh, and Docker Compose or ccm
- One programming language with the DataStax driver
- 8 GB of RAM or more for the cluster laboratories
- The programme's shared foundations
Common questions
- What does the Apache Cassandra: Query-First Modeling and Tunable Consistency course cover?
- It is 5 levels and 7 lessons: Beginner - Foundations; Intermediate - Application Behaviour; Advanced - Performance and Reliability; Expert - Security and Production Architecture; Capstone. Each level ends with a quiz, and the last one is an exam over the whole course.
- How long does it take?
- About 59 minutes of reading and exercises - roughly 1 hours. It is self-paced with no cohort and no start date, so you can leave and come back and the site remembers where you were.
- What do I need to know first?
- Apache Cassandra 5 or later, as a three-node cluster. cqlsh, and Docker Compose or ccm. One programming language with the DataStax driver. 8 GB of RAM or more for the cluster laboratories. The programme's shared foundations.
- Is it free?
- Yes. Every lesson, example and quiz in this course is free to read, and you do not need an account to read them. Signing in only adds progress tracking and quiz results.
- What will I be able to do afterwards?
- Explain the ring, token ranges, the coordinator and virtual nodes. Use CQL fluently, and name precisely where it differs from SQL. Design partition and clustering keys, and bound partition size deliberately. Apply query-first modelling: enumerate queries, then build one table per query. Denormalise correctly, and maintain the copies you create. Use collections, UDTs and TTL, and state the cost of each. Choose a consistency level per statement, and apply the R + W > RF arithmetic. Explain last-write-wins conflict resolution and the risk of clock skew. Use lightweight transactions, and state what they cost. Explain why a multi-partition batch is usually a mistake. Configure driver retry, speculative execution and token-aware routing. Explain LSM storage, SSTables and the read path. Choose a compaction strategy with a reason. Diagnose tombstones, and explain why a queue is an anti-pattern. Read a trace and act on what it shows. Configure replication across racks and datacentres. Run repair, understand hinted handoff, and replace a node. Implement authentication, authorisation and TLS. Produce a deployment, capacity and cost checklist.