Apache Cassandra
Cassandra is a distributed, wide-column NoSQL database designed for enormous write throughput and always-on availability across many nodes — even spanning data centers. There's no single primary; every node can take writes, which is what makes it so resilient and horizontally scalable.
The price of that scale is a different way of thinking: you model around your queries, not your entities. There are no joins, denormalization is the norm, and your partition key choices determine everything about performance.
TL;DR
- Built for high write throughput and horizontal scale with no single point of failure.
- Data modeling is query-driven — design tables for the reads you'll run.
- Consistency is tunable per query (from one node to a quorum).
- No joins; denormalize deliberately and avoid unbounded partitions.
Quick Example
A table is shaped by its primary key — a partition key (distribution) plus clustering columns (order within a partition):
Core Concepts
- Partition key — determines which node stores the row; the most important design choice.
- Clustering columns — order rows within a partition.
- Replication & consistency levels — how many replicas must respond (
ONE,QUORUM,ALL). - Ring architecture — nodes share a token range; data is distributed by partition-key hash.
Data Modeling
- Design tables per query — it's normal to store the same data multiple ways.
- Avoid unbounded partitions — a partition that grows forever becomes a hotspot.
- Denormalize intentionally — there are no joins, so duplication is expected.
Best Practices
- Pick partition keys that spread load evenly and keep partitions bounded.
- Choose consistency levels to match each operation's correctness needs.
- Plan for operations: repairs, compaction, and monitoring are real work.
- Write idempotently — retries and tunable consistency can re-deliver writes.
Comparison: Cassandra vs DynamoDB
See DynamoDB.
Common Mistakes
Modeling relational workloads
Hot or unbounded partitions
FAQ
When should I use Cassandra?
For write-heavy, always-on, horizontally scaled workloads with known query patterns — time-series and event data per entity, high-volume ingestion, and geographically distributed systems. If you need joins, ad-hoc queries, or strong single-node consistency, a relational database fits better.
What are consistency levels?
They let you choose, per operation, how many replicas must acknowledge a read or write — e.g. ONE (fast, weaker) up to QUORUM or ALL (slower, stronger). This tunes the CAP trade-off between latency/availability and consistency for each query.
Why can't I do joins in Cassandra?
Joins require gathering data across partitions/nodes, which doesn't scale in Cassandra's distributed model. Instead you denormalize — store data pre-joined in tables shaped for each query you need to serve.
Cassandra or DynamoDB?
Cassandra if you want an open-source, self-managed (or multi-cloud) wide-column store with tunable consistency. DynamoDB if you want a fully managed AWS service with no cluster to operate. Both reward access-pattern-first modeling.
Related Topics
- DynamoDB — Managed NoSQL with similar modeling
- Databases — Choosing a data store
- System Design — Distributed data systems
- Database Replication — Replication concepts
- Microservices — Service-owned data stores