What Cassandra is
TrapDon't call Cassandra schemaless. Every CQL table has typed columns, but adding a column is cheap.
Asked in interviews
AskedWhat are the main differences between Cassandra and traditional RDBMS?gc_grace_seconds , 10 days by default, or deleted data can come back.QUORUM is 2. Any 2 replicas a read picks include one with the write. A ONE read can reach C before the hint does.TrapDon't call Cassandra schemaless. Every CQL table has typed columns, but adding a column is cheap.
Asked in interviews
AskedWhat are the main differences between Cassandra and traditional RDBMS?nodetool getendpoints app users 42num_tokens: 16Virtual nodes (vnodes). 16 is the default since 4.0, down from 256.TipThe default partitioner is Murmur3. Hashing keys onto a ring of nodes is called consistent hashing.
TrapMore tokens per node have a cost. More combinations of failed nodes can take part of the ring offline, and there are more repairs to run.
nodetool statusUN means up and normal, and DN means down.TrapSeed nodes only help new nodes join. They aren't masters, and any node can coordinate any request.
{'class': 'NetworkTopologyStrategy', 'dc1': 3, 'dc2': 2}Set it in the keyspace's replication option.{'class': 'SimpleStrategy', 'replication_factor': 3}It ignores datacenters and racks.endpoint_snitch. Production clusters use GossipingPropertyFileSnitch .TipUse Network in production, even with one datacenter. It puts each datacenter's replicas on different racks.
CONSISTENCY ONEGet the fastest reads and writesCONSISTENCY LOCAL_QUORUMRead your writes within one datacenterCONSISTENCY QUORUMRead your writes across the clusterCONSISTENCY ALLWait for every replicaTipLatest means a read sees the last write when reads and writes use that level. For LOCAL_QUORUM, that holds only within one DC.
Asked in interviews
AskedWhat are the different consistency levels in Cassandra?ONE, it's AP. It keeps answering during a network partition, but reads may be stale.QUORUM does in a network partitionReads and writes see the latest write, but fail on the side without a majority.QUORUM is 2, and 2 + 2 > 3.max_hint_window: 3hHinted handoff. The coordinator stores missed writes as hints, for up to 3 hours of downtime.CONSISTENCY ANYFor writes only. A stored hint counts, so the write is lost if the coordinator fails first.TipA node down longer than max_hint_window gets no more hints. It stays out of sync until you run repair.
TrapAt ONE, only one replica answers, so read repair never runs.
PRIMARY KEY ((sensor_id, day), ts)The inner parentheses hold the partition key.WITH CLUSTERING ORDER BY (ts DESC)TrapYou set the primary key and the clustering order when you create a table. Changing either means a new table and a data copy.
TrapDon't start from the entities. A table built around an entity rarely answers the queries the app runs.
PRIMARY KEY (user_id, order_date, order_id)One partition per user, and one row per order, sorted by date.name text STATICA static column.order_ids set<uuid>A collection. Use one only when the list stays small.TipSeparate tables also work. The app joins them with two queries, which costs two round trips.
TrapCassandra reads a whole collection at once. A list that keeps growing belongs in its own table.
Asked in interviews
AskedHow do you model a one-to-many relationship in Cassandra?nodetool tablestats app.eventsTrapDon't make the date alone the partition key. All of that day's writes then land on the same few nodes.
ALTER TABLE users ADD phone text;ALTER TABLE users DROP phone;Reads hide it at once. Compaction removes the data later.TRUNCATE users;Every node must be up.DROP TABLE users;DROP KEYSPACE app;nodetool describeclusterTrapYou can't change a column's type or rename a non-key column. Add a new column instead.
Asked in interviews
AskedHow does Cassandra handle schema changes?text, int, bigint, double, boolean, timestamp, uuid, timeuuid and blob.set for sorted unique values, list for ordered ones, and map for key-value pairs.CREATE TYPE address (street text, city text);A user-defined type (UDT).TipInside a collection, a UDT must be frozen and written whole. A non-frozen UDT column can change one field.
USING TTL 86400Add it to an INSERT or UPDATE. The TTL is in seconds.WITH default_time_to_live = 86400By default, values never expire.TipExpired values turn into tombstones. Compaction removes them after gc_.
TrapA TTL belongs to each value you write. Updating a column resets its TTL.
Asked in interviews
AskedWhat is TTL in Cassandra?SET views = views + 1views is a counter column. You can only add or subtract.TipEach counter update reads the current value first, so it costs more than a normal write.
TrapCounters can't have a TTL. Don't update a counter again after you delete it.
Asked in interviews
AskedExplain counter columns in Cassandra.SELECT * FROM events WHERE user_id = ?;WHERE user_id = ? AND event_time > ?ALLOW FILTERINGCassandra may read every partition, then drop the rows that don't match.TipUse ALLOW FILTERING only on small data, like one partition. Otherwise add a table keyed for the query, or an SAI index.
TrapAn ALLOW FILTERING query slows as the table grows, even when it returns few rows.
Asked in interviews
AskedWhat does ALLOW FILTERING do, and why is it dangerous?CREATE INDEX ON users (country) USING 'sai';A storage-attached index (SAI). It also handles numeric ranges.CREATE INDEX ON users (country);A legacy secondary index. Each node indexes only its own data.ORDER BY embedding ANN OF [0.1, 0.2] LIMIT 5It needs a vector<float, n> column with an SAI index.TipMaterialized views are experimental and off by default. For a busy query, keep a second table keyed for it.
TrapOn 5.0, a plain CREATE INDEX still builds the legacy index. Add USING 'sai'.
OFFSET, and a paging state only moves forward.WHERE token(user_id) > ? LIMIT 100TrapA paging state works only with the query that returned it.
Asked in interviews
AskedHow do you implement pagination in Cassandra?DELETE FROM users WHERE id = ?;Cassandra writes a tombstone, a delete marker with a timestamp.WITH gc_grace_seconds = 86400010 days is the default. After that, compaction can remove them.TrapRepair within gc_. Otherwise a replica that missed the delete can bring the data back.
Asked in interviews
AskedWhat are tombstones in Cassandra?BEGIN BATCHAPPLY BATCH;A logged batch, the default. Its batch log makes every write land eventually.BEGIN UNLOGGED BATCHA failed batch may then apply only partly.TrapA batch has no rollback and no isolation across partitions. Other clients can see part of it.
Asked in interviews
AskedWhat is the difference between batches and transactions in Cassandra?INSERT INTO users (id, email) VALUES (?, ?);It silently overwrites the old values. INSERT and UPDATE are both upserts.IF NOT EXISTSAn LWT. The result's [applied] column says if it ran.IF email = 'old@example.com' Compare and set. The replicas agree on it through Paxos.TipLWTs are linearizable, so every client sees them in one order. Use them for unique usernames or stock counts.
TrapAn LWT covers one partition. Cassandra 6.0, in alpha as of October 2026, adds Accord for transactions across partitions.
TipWrites are fast because no file changes in place. SSTables never change, and compaction merges them later.
Asked in interviews
AskedDescribe the write path in Cassandra.WITH bloom_filter_fp_chance = 0.001The default is 0.01, or 0.1 with LCS.nodetool tablehistograms app usersTipCassandra 5.0 adds the BTI SSTable format. Its trie index replaces the key cache and index lookups.
{'class': 'SizeTieredCompactionStrategy'} STCS, still the default. It suits heavy writes.{'class': 'LeveledCompactionStrategy'} LCS. It suits heavy reads.{'class': 'TimeWindowCompactionStrategy'} TWCS. It suits time series that expire with a TTL.{'class': 'UnifiedCompactionStrategy'} UCS. It can act like any of the others.TipCompaction keeps the newest version of each row and drops tombstones past their grace period.
TrapA growing backlog of pending compactions means each read touches more SSTables.
Asked in interviews
AskedWhat is compaction in Cassandra and why is it important?nodetool repair -prRun it on every node.nodetool repair runsAn incremental repair. It checks only data written since the last one.nodetool repair --fullTipEach replica builds a Merkle tree, a tree of hashes. Replicas stream only the ranges whose hashes differ.
TrapDon't rely on hints and read repair. They're best effort, and only nodetool repair compares all the data.
Asked in interviews
AskedWhat is nodetool repair, and why do you need to run it regularly?nodetool cleanupRun it on the old nodes after a node joins.nodetool decommissionIt streams its data to the new owners first.nodetool removenode <host-id>The other replicas stream its data instead.-Dcassandra.replace_address_first_boot=<ip> It takes over the same token ranges.TipIf the dead node was down longer than max_hint_window, run repair after you replace it.
Asked in interviews
AskedWhat happens when you add or remove a node from a Cassandra cluster?nodetool snapshot -t nightly appIt hard-links the SSTables, so it's fast. Run it on every node.nodetool enablebackupIncremental backups. They're off by default.nodetool import app users /backup/usersIt loads SSTables from any folder. It replaced nodetool refresh, deprecated in 4.0.sstableloader -d 10.0.0.1 app/usersnodetool clearsnapshot -t nightlyTipTRUNCATE and DROP TABLE take a snapshot first by default, so you can still restore the data.
TrapA snapshot sits on the same disk as the data. Copy it off the node, or one failed disk loses both.
Asked in interviews
AskedHow do you backup and restore data in Cassandra?nodetool tpstatsPending or blocked tasks show the overloaded stage.nodetool proxyhistogramsIt shows latency at the coordinator.SELECT * FROM system_views.thread_pools; TipCassandra exposes metrics on each node through JMX and virtual tables. Collect them with a tool like Prometheus and Grafana.
TrapDataStax OpsCenter works only with DataStax Enterprise. It can't monitor open-source Cassandra.
Asked in interviews
AskedHow do you monitor Cassandra cluster health?TRACING ONRun it in cqlsh, then run the query.nodetool enablefullquerylog --path /var/lib/fqlTipThe fix is often in the data model. Split large partitions, drop ALLOW FILTERING, and use no higher consistency than you need.
Asked in interviews
AskedHow do you troubleshoot performance issues in Cassandra?memtable_heap_space: 2048MiBBigger memtables use more heap.concurrent_writes: 128About 8 per CPU core.TipWrite at the lowest consistency level the app accepts. ONE writes fastest.
TrapEach speedup has a cost. Tiered compaction slows reads, and a lower consistency level weakens guarantees.
Asked in interviews
AskedHow do you optimize Cassandra for write-heavy workloads?Nothing matches. Try a shorter word, or clear the search.
With Pro, you can:
Already have Pro? Sign in