Cassandra interview questions and answers: data modeling, consistency and operations
Cassandra interview questions revolve around one idea: you design tables for the queries you will run, because a query must name its partition key and can only slice along clustering columns. Interviewers then test consistency levels and replication (when QUORUM reads see QUORUM writes), the write path that makes writes cheap, compaction choices, and why tombstones and missed repairs cause slow reads and deleted data coming back. Experienced Cassandra engineers are also asked to size partitions and run the cluster through node failures.
By Evin JohnPublished 8 min read
How Cassandra is tested in interviews
Cassandra comes up in backend and data platform interviews at companies with high write volume: messaging, IoT telemetry, activity feeds, fraud signals. The modeling round is the core. You get a feature, such as "show the latest messages in a conversation" or "readings for a sensor over a day", and are expected to write the table, the primary key and the query. Operations-heavy roles add questions on node failures, repair schedules, compaction and capacity. Anyone coming from relational databases is checked for habits that do not carry over, such as joins, ad hoc filters and normalizing everything.
- Concept screenArchitecture basics: peer-to-peer ring, replication factor, consistency levels, the role of the partition key.
- Data modeling roundGiven two or three queries, design tables, primary keys and clustering order, and say how big each partition can grow.
- Operations and scenariosSlow reads from tombstones, a node down for a day, a hot partition, choosing compaction, multi-datacenter setup.
Fundamentals: architecture and the primary key
| Question | What it tests | What a strong answer shows |
|---|---|---|
| How is Cassandra's architecture different from a primary-replica database? | Architecture | Every node is equal. Any node can coordinate a request, data is spread around a token ring by consistent hashing, and there is no single leader to fail over. |
| What is the difference between the partition key and clustering columns? | Primary key | The partition key is hashed to a token that decides which nodes store the row. Clustering columns sort rows inside that partition on disk. Together they make the primary key unique. |
| What is a composite partition key, and why use one? | Partition sizing | Several columns in the inner parentheses, such as (sensor_id, day). It spreads one entity's data over many partitions, so none grows without bound. |
| Is INSERT different from UPDATE in Cassandra? | Write semantics | Both are upserts. Neither reads first; each column carries a write timestamp, and the newest timestamp wins when versions meet. |
| What is the replication factor? | Replication | How many nodes hold a copy of each partition, set per keyspace and, with NetworkTopologyStrategy, per datacenter. SimpleStrategy is for single-datacenter test clusters. |
| What do gossip and seed nodes do? | Membership | Nodes exchange state through gossip every second or so. Seeds are contact points new nodes use to join; they are not special in serving data. |
| What are virtual nodes? | Token ownership | Each node owns many small token ranges instead of one, which spreads data more evenly and speeds up rebuilding a node. Newer releases default to fewer tokens per node than early ones did. |
| What is the snitch for? | Topology | It tells Cassandra which rack and datacenter a node belongs to, so replicas land on different racks and requests stay in the local datacenter. |
Data modeling: start from the query
The modeling round decides most Cassandra interviews. Interviewers want to hear the queries first, then a table per query, then the partition size estimate. The example below models a chat feature where the screen shows the newest messages of one conversation and scrolls back in time.
CREATE TABLE chat.messages_by_conversation (
conversation_id uuid,
bucket text, -- e.g. '2026-12', month of the message
sent_at timeuuid,
sender_id uuid,
body text,
PRIMARY KEY ((conversation_id, bucket), sent_at)
) WITH CLUSTERING ORDER BY (sent_at DESC)
AND compaction = {'class': 'TimeWindowCompactionStrategy',
'compaction_window_unit': 'DAYS',
'compaction_window_size': 7};
-- Latest 50 messages in the current month's bucket
SELECT sender_id, sent_at, body
FROM chat.messages_by_conversation
WHERE conversation_id = 6f1c2a9e-3b7d-4c55-9a43-2f0e8b1d7c10
AND bucket = '2026-12'
LIMIT 50;
-- Older page: everything before the last message the client has
SELECT sender_id, sent_at, body
FROM chat.messages_by_conversation
WHERE conversation_id = 6f1c2a9e-3b7d-4c55-9a43-2f0e8b1d7c10
AND bucket = '2026-12'
AND sent_at < 4f3a1c60-d1a2-11f0-8de9-0242ac120002
LIMIT 50;- Why not just use conversation_id as the partition key? A busy group chat would grow one partition forever. The month bucket caps it; the client walks to the previous bucket when a page comes back short.
- Why timeuuid for sent_at? It sorts by time and is unique, so two messages in the same millisecond do not overwrite each other, which a plain timestamp clustering column could.
- Why can you not query messages by sender in this table? sender_id is neither a partition key nor a clustering column. You would need another table keyed by sender, written at the same time, or accept a scan with ALLOW FILTERING, which you should not in production.
- What range queries are allowed? Equality on every partition key column, then clustering columns restricted in order, with a range only on the last one you restrict. You cannot skip the first clustering column and filter on the second.
- How do you keep several denormalized tables in sync? Write all of them per event, often in a logged batch so they eventually all apply, and make the writes idempotent so retries are safe. Accept that readers may briefly see one table ahead of another.
- When are secondary indexes acceptable? On low-volume queries that also restrict the partition key, or with the newer storage-attached indexes where your version supports them. A plain secondary index query without the partition key fans out to every node.
- What about materialized views? They maintain a second table for you but have a history of consistency issues and are treated as experimental in many releases. Many teams write the second table themselves.
Consistency levels and replication
RF = 3
levels = {"ONE": 1, "QUORUM": RF // 2 + 1, "ALL": RF}
for w_name, w in levels.items():
for r_name, r in levels.items():
overlap = "reads see the write" if r + w > RF else "may read stale data"
print(f"write {w_name:<6} read {r_name:<6} -> {overlap}")
# write ONE read ONE -> may read stale data
# write ONE read QUORUM -> may read stale data
# write ONE read ALL -> reads see the write
# write QUORUM read ONE -> may read stale data
# write QUORUM read QUORUM -> reads see the write
# ... and every pair that includes ALL also overlaps| Question | What it tests | What a strong answer shows |
|---|---|---|
| What does QUORUM mean with a replication factor of 3? | Tunable consistency | Two replicas must answer. If writes and reads both use QUORUM, at least one replica in every read has the latest write. |
| LOCAL_QUORUM or QUORUM in a multi-datacenter cluster? | Latency | LOCAL_QUORUM counts only replicas in the coordinator's datacenter, so requests do not wait on another region. QUORUM counts across all datacenters and pays the cross-region latency. |
| What does consistency level ONE trade away? | Availability versus freshness | It is fast and survives more failures, but a read can hit a replica that missed a recent write. |
| What happens when a replica is down during a write? | Hinted handoff | If enough replicas acknowledge for the requested level, the write succeeds, and the coordinator stores a hint to replay when the node returns, for a limited window. Beyond that window, repair has to fix it. |
| How does Cassandra fix replicas that disagree? | Anti-entropy | Read repair fixes mismatches seen during reads; full or incremental repair compares Merkle trees of token ranges and streams the differences. |
| Where does Cassandra sit in CAP terms? | Theory | It is usually described as AP with tunable consistency: with ALL or QUORUM you trade availability for stronger reads, per request. |
| What are lightweight transactions? | Compare-and-set | IF NOT EXISTS or IF column = value uses Paxos among replicas to make a conditional write linearizable. It needs several round trips, so use it for rare cases such as claiming a username. |
Storage engine: writes, reads, compaction and tombstones
- Why are writes in Cassandra fast? A write appends to the commit log and updates an in-memory memtable, with no read and no in-place update. Full memtables flush to immutable SSTables on disk.
- What happens on a read? The node checks the memtable and the SSTables that might hold the partition. Bloom filters skip SSTables that definitely do not, partition indexes find the offset, and versions of each cell are merged by timestamp.
- What does compaction do? It merges SSTables, keeps the newest version of each cell, drops expired data and old tombstones, and so reduces how many files a read touches.
- How do you choose a compaction strategy? Size-tiered for write-heavy workloads with few updates. Leveled for read-heavy tables with frequent updates, at the cost of more disk I/O. Time-window for time series written once and expired by TTL. Newer releases also offer a unified strategy; check what your version supports.
- What is a tombstone? A delete marker with a timestamp. Data is not removed immediately because other replicas may still hold the old value and need to learn about the delete.
- What is gc_grace_seconds? How long tombstones are kept before compaction may purge them, ten days by default. If a replica misses a delete and repair does not run within that time, the deleted data can come back.
- Why do queues and frequently deleted rows hurt Cassandra? Reads scan past piles of tombstones before finding live data, which slows them and can trip the tombstone failure threshold. Model queues differently, or use a time-bucketed design with TTL and time-window compaction.
- Are batches a performance tool? No. A logged batch across partitions adds coordinator work through the batch log; it gives eventual all-or-nothing, not isolation. A batch to a single partition is efficient; a big multi-partition batch is an anti-pattern.
Senior and operations scenarios
| Question | What it tests | What a strong answer shows |
|---|---|---|
| One node is at high CPU while the others idle. Why? | Hot partitions | A popular partition key, such as a celebrity's feed or a global counter, sends its traffic to the same replicas. Spread it with a bucket or shard suffix in the partition key. |
| How large should a partition be? | Sizing | Bounded. A common rule of thumb keeps partitions well under a hundred megabytes and avoids unbounded row counts. Estimate rows per partition times row size during design. |
| A node was down for two weeks. Can you just restart it? | Repair and zombies | Not safely if it was down longer than gc_grace_seconds: it may hold data that was deleted elsewhere. Replace or rebuild it instead of letting it rejoin with stale data. |
| How do you add capacity? | Scaling | Bootstrap new nodes, which take over token ranges and stream data; then run cleanup on the old nodes to drop data they no longer own. Watch streaming throughput and disk headroom. |
| How should the application driver be configured? | Client side | Token-aware and datacenter-aware load balancing, prepared statements, paging with a fetch size, idempotent statements marked so retries and speculative execution are safe. |
| Are counters safe to retry? | Counters | No. A counter increment is not idempotent, so a timeout followed by a retry can double-count. Use them where small errors are acceptable. |
| When would you not pick Cassandra? | Judgment | Ad hoc analytics, many-table joins, strong multi-row transactions, or small datasets that a relational database handles easily. Its strength is predictable writes and key-based reads at scale. |
| How does it compare with DynamoDB? | Trade-offs | Similar partition-key thinking. DynamoDB is managed with capacity modes and AWS integration; Cassandra runs anywhere and exposes tunable consistency and compaction, with the operational load that implies. |
Fictional example
- Interviewer
- Dashboards show one sensor's readings for a chosen day, newest first. We keep 90 days. Walk me through the table.
- Candidate
- The only query is sensor plus day, so the partition key is (sensor_id, day) and the clustering column is reading_time descending. One reading a minute is 1,440 rows a day per partition, small and bounded. I would set a 90-day TTL on insert so data expires on its own, and use time-window compaction with one-day windows, so whole SSTables expire together instead of leaving tombstones scattered across files. Writes go at LOCAL_QUORUM with a replication factor of 3 per datacenter, and dashboard reads at LOCAL_ONE or LOCAL_QUORUM depending on how fresh they must be. If product later wants hourly averages, I would write a second rollup table from a stream processor rather than scanning raw partitions.
Two-week Cassandra practice plan
- Days 1 to 3: model five features (chat, feed, sensor data, user sessions, orders by customer) on paper. Write the query first each time.
- Days 4 to 6: run a local single node or a small cluster in containers if your machine allows, create the tables and try queries CQL rejects, reading each error.
- Days 7 to 9: study consistency levels with the replica arithmetic above, then explain hinted handoff, read repair and full repair in your own words.
- Days 10 to 12: compare the compaction strategies and write a short note on tombstones and gc_grace_seconds.
- Days 13 and 14: answer the scenario table out loud, two minutes each, and time one full modeling exercise.
Cassandra modeling has a close cousin in DynamoDB interview questions, where the same partition-first thinking meets a managed service. Search over the same data usually lands in Elasticsearch. For the theory behind tunable consistency and partitioning, read consistency and CAP and sharding, and for pipeline roles see data engineer interview questions.
A modeling answer is easier to tighten when you can read it back. Natively, an AI interview assistant for Mac and Windows, transcribes a mock round on your computer, so you can check whether you stated the query before the table. In practice it can read a schema or a nodetool output from a screenshot and suggest what to examine, and with Pro or the free trial it takes the résumé and job description you add into account. The transcript and notes are kept for later review.
Questions people ask
What Cassandra questions are asked in interviews?
Expect the ring architecture, partition keys versus clustering columns, designing tables per query, consistency levels and replication, hinted handoff and repair, the write and read paths, compaction strategies, tombstones, batches and lightweight transactions.
What is the difference between a partition key and a clustering column in Cassandra?
The partition key is hashed to decide which nodes store the data. Clustering columns sort rows within a partition and define which range queries you can run inside it.
What does QUORUM mean in Cassandra?
A majority of the replicas for that partition must respond, two out of three with a replication factor of 3. Writing and reading at QUORUM means every read overlaps with the latest successful write.
Why are tombstones a problem in Cassandra?
Deletes write markers that stay until gc_grace_seconds passes and compaction removes them. Reads must skip them, so tables with many deletes get slow, and a replica that misses repair in that window can bring deleted data back.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
