CASSANDRA Architecture and Data Model 2 — Questions and Answers
Question 1: What is an SSTable in Apache Cassandra?
- A mutable in-memory structure
- An immutable on-disk file that stores sorted partition data (Correct answer)
- A write-ahead log
- A network protocol buffer
Correct answer: An immutable on-disk file that stores sorted partition data
SSTables (Sorted String Tables) are immutable, on-disk files written when a MemTable is flushed, containing sorted partition data.
Question 2: What role does the CommitLog play in Cassandra's write path?
- It indexes partitions for fast lookup
- It provides durability by recording every write before the MemTable (Correct answer)
- It merges SSTables during compaction
- It caches frequently read rows
Correct answer: It provides durability by recording every write before the MemTable
The CommitLog is written to first on every mutation to ensure durability in case of a node crash before the MemTable is flushed.
Question 3: What is the 'replication factor' in a Cassandra keyspace?
- The compression ratio of SSTables
- The number of copies of each partition stored across the cluster (Correct answer)
- The number of nodes in the cluster
- The consistency level for reads
Correct answer: The number of copies of each partition stored across the cluster
The replication factor defines how many nodes store a replica of each partition, directly affecting fault tolerance.
Question 4: Which compaction strategy is best suited for time-series data that is mostly appended and rarely updated?
- SizeTieredCompactionStrategy (STCS)
- LeveledCompactionStrategy (LCS)
- TimeWindowCompactionStrategy (TWCS) (Correct answer)
- UnifiedCompactionStrategy (UCS)
Correct answer: TimeWindowCompactionStrategy (TWCS)
TWCS groups SSTables into time windows and compacts within each window, making it ideal for time-series data with little or no overwrites.
Question 5: What is 'tombstone' in Cassandra?
- A marker written at node startup
- A deletion marker stored in SSTables to represent deleted data (Correct answer)
- A log entry for schema changes
- A backup snapshot file
Correct answer: A deletion marker stored in SSTables to represent deleted data
A tombstone is a deletion marker written to an SSTable that tells Cassandra to ignore older versions of that data during reads.
Question 6: What does 'vnodes' (virtual nodes) provide in Cassandra?
- Isolated namespaces for keyspaces
- More even data distribution by assigning multiple token ranges per physical node (Correct answer)
- Virtual replicas for read performance
- Logical shards for multi-tenancy
Correct answer: More even data distribution by assigning multiple token ranges per physical node
Vnodes assign multiple non-contiguous token ranges to each physical node, resulting in more balanced data distribution and easier cluster scaling.
What is an SSTable in Apache Cassandra?