CASSANDRA Performance and Tuning 1 — Questions and Answers
Question 1: What consistency level in Cassandra offers the lowest latency but the weakest consistency guarantee?
- ALL
- QUORUM
- ONE (Correct answer)
- LOCAL_QUORUM
Correct answer: ONE
Consistency level ONE requires only a single replica to respond, giving the lowest latency but risking stale reads if another replica has a newer version.
Question 2: What is the formula for calculating quorum in a Cassandra cluster?
- (replication_factor / 2)
- (replication_factor / 2) + 1 (Correct answer)
- replication_factor - 1
- replication_factor * 0.75
Correct answer: (replication_factor / 2) + 1
Quorum is calculated as floor(replication_factor / 2) + 1, ensuring a majority of replicas must agree before a read or write succeeds.
Question 3: What does 'speculative execution' do in Cassandra drivers?
- Pre-fetches the next page of results
- Sends duplicate requests to multiple replicas and uses the fastest response to reduce tail latency (Correct answer)
- Executes a query on a secondary index speculatively
- Pre-compiles CQL statements to reduce parse overhead
Correct answer: Sends duplicate requests to multiple replicas and uses the fastest response to reduce tail latency
Speculative execution fires off the same query to an additional replica after a configurable delay, reducing tail latency by using the faster response.
Question 4: Which Cassandra compaction strategy minimizes read amplification and is best for mixed read/write workloads?
- SizeTieredCompactionStrategy (STCS)
- LeveledCompactionStrategy (LCS) (Correct answer)
- TimeWindowCompactionStrategy (TWCS)
- DateTieredCompactionStrategy (DTCS)
Correct answer: LeveledCompactionStrategy (LCS)
LCS maintains SSTables in levels with size limits, minimizing read amplification to roughly 1 SSTable per read at the cost of higher write I/O.
Question 5: What is the 'row cache' in Cassandra and when should it be used?
- An in-JVM cache of entire partitions for tables with very few partitions and high read frequency (Correct answer)
- A disk-based cache for recently flushed SSTables
- A client-side cache maintained by the driver
- A cache of CQL prepared statement results
Correct answer: An in-JVM cache of entire partitions for tables with very few partitions and high read frequency
The row cache stores entire partition rows in off-heap memory and is only beneficial for tables with a small number of frequently accessed partitions.
Question 6: What tool can be used to run benchmark load tests against a Cassandra cluster?
- nodetool benchmark
- cassandra-stress (Correct answer)
- cqlsh --bench
- sstableloader --test
Correct answer: cassandra-stress
cassandra-stress is a built-in benchmarking tool that generates configurable read/write workloads to measure cluster throughput and latency.
What consistency level in Cassandra offers the lowest latency but the weakest consistency guarantee?