Skip to content
SeeItFlow
Interactive guide · 9 chapters · ~18 min read

Cassandra in Production

Cassandra's masterless design means there's no single dashboard that tells you a node is unhealthy — you have to know what to look for in compaction stats, hinted handoff, and repair status. This section covers the configs, tuning, and operational signals that separate a demo cluster from one that survives real traffic and real node failures.

Mangesh MandlikLast updated:
01 · Data modeling

Data Modeling

In Cassandra, you model your data around your queries, not the other way around — the opposite of relational normalization.

Because Cassandra has no joins and no ad-hoc query planner like a relational database, every table should be designed to answer exactly one query pattern efficiently. This often means denormalizing the same data into several tables, each shaped for a different read path — a technique commonly called 'query-first' or 'query-driven' modeling.

02 · Partition design

Partition Design

The partition key you choose determines how evenly data and traffic spread across the cluster — get it wrong, and no amount of extra nodes will help.

Avoiding hot partitions

A partition key with low cardinality (e.g. a single tenant ID for a huge multi-tenant table) concentrates data and traffic on a handful of nodes. Composite keys (e.g. tenant_id + day) spread load more evenly.

Partition size limits

Very large partitions (millions of cells) hurt read latency, compaction, and repair times. A commonly quoted guideline (a heuristic, not a hard limit — the right ceiling depends on row width, hardware and Cassandra version) is to keep partitions under ~100MB and a few hundred thousand rows.

03 · Replication

Replication Strategies

Cassandra supports pluggable replication strategies — the choice matters a lot once you go multi-datacenter.

SimpleStrategy

Places replicas on the next N-1 nodes clockwise on the ring, ignoring datacenter or rack topology. Fine for single-DC test clusters, but not recommended for production.

NetworkTopologyStrategy

Lets you specify a replication factor per datacenter (e.g. {'dc1': 3, 'dc2': 3}), and is rack-aware within a DC to avoid placing all replicas on the same physical rack. This is the production standard.

04 · Consistency tuning

Cassandra Performance Tuning: Consistency Levels

Consistency level is chosen per query — production systems typically mix levels depending on how critical a given read or write is. Lower levels wait on fewer replicas and can respond faster, at the cost of weaker guarantees.

LOCAL_QUORUM

The most common production setting for multi-datacenter clusters: quorum within the local datacenter only, avoiding cross-DC latency on the hot path while still requiring a majority.

Read-your-writes

To guarantee a client reads its own recent write, ensure R + W > RF for that keyspace's consistency levels — e.g. QUORUM writes + QUORUM reads with RF=3.

05 · Scaling

Scaling

Cassandra scales by adding nodes — each new node takes over a slice of the token ring and begins serving traffic for it.

Vnodes

Modern Cassandra assigns each physical node many small token ranges ('virtual nodes') instead of one large range, which spreads the rebalancing load across the whole cluster when a node joins or leaves, rather than concentrating it on two neighbors.

Streaming

When a node joins, the cluster streams the relevant data ranges to it directly from existing replicas — a bandwidth- and disk-intensive operation that should be scheduled and monitored carefully in production.

06 · Repair

Repair

Repair is not optional maintenance — it's what keeps replicas consistent over the long run, especially for data that's rarely read.

nodetool repair

Compares Merkle trees of data ranges across replicas and streams over any differences. Every token range should be repaired at least once within the gc_grace_seconds window (default 10 days); a weekly cadence is a common way to keep margin under that window, not a rule. Missing it risks resurrecting deleted data (the 'zombie' tombstone problem). Full and incremental repair behave differently and incremental repair was reworked in 4.0 — check the docs for your version before choosing.

07 · Monitoring

Monitoring

The metrics that matter most in Cassandra are different from a typical relational database — watch compaction, GC pauses, and read/write latency percentiles closely.

Key metrics

Read/write latency (p99, not just average), pending compactions, dropped mutations, hinted handoff backlog, and JVM garbage collection pause times are the highest-signal metrics for cluster health.

Compaction strategy per table

Pending compactions is a symptom; the per-table strategy is often the cause. Use STCS (the default) for write-heavy tables, LCS when reads dominate and latency matters and you can afford the extra write I/O, and TWCS for write-once time-series data with a TTL (avoid updates, manual deletes and out-of-order writes on it). Whatever you choose, keep disk headroom: STCS can temporarily need a large share of free space for big merges. Mechanics and trade-offs are explained in the write path and compaction chapter.

08 · Common issues

Common Production Issues

A handful of failure modes account for the vast majority of real-world Cassandra incidents.

Hot partitions

Poor partition key choice concentrates load on a few nodes, causing localized latency spikes even though the rest of the cluster is healthy.

Large partitions

Partitions that grow unbounded slow down reads, compaction, and repair — and can even cause out-of-memory errors during compaction.

Tombstone overload

Frequent deletes on the same partition accumulate tombstones that must be scanned on every read, sometimes causing reads to fail outright once a threshold is exceeded.

09 · Debugging

Debugging

Cassandra ships with strong operational tooling — nodetool is the first stop for almost every production question.

nodetool status / tpstats

nodetool status shows per-node health and load; nodetool tpstats shows thread pool queues and dropped messages — the fastest way to spot an overloaded node.

Tracing

TRACING ON in cqlsh (or per-query tracing) shows exactly which replicas were contacted and how long each step took — invaluable for diagnosing a single slow query.

Key takeaways
  1. 01Model tables around queries, not entities — denormalization is expected, not a code smell.
  2. 02Choose partition keys that spread load evenly and keep partitions bounded in size.
  3. 03Use NetworkTopologyStrategy in production, even for a single datacenter.
  4. 04Match consistency levels to the read-your-writes guarantee each workload actually needs (R + W > RF).
  5. 05Repair regularly and within gc_grace_seconds to reduce the risk of resurrecting deleted data.
  6. 06Watch pending compactions and p99 latency as the earliest signals of cluster stress.