Scrivio Interview library
DebuggingIntermediate7 min read · updated 13 November 2026

Read latency on a Cassandra table rose from 3 ms to 25 ms over a month. nodetool tablehistograms shows reads touching a median of 9 SSTables, and nodetool tablestats reports a Bloom filter false ratio of 0.28 for the table, whose bloom_filter_fp_chance is 0.1.

Explain how Bloom filters are used on the read path of an LSM storage engine, why they are not helping here, and what you would change.

Each SSTable carries a Bloom filter of its partition keys, and a read asks every filter first so it opens only the SSTables that might hold the key. Here the filters are built with a 10 percent false positive chance and reads are spread over about 9 SSTables, so many reads open files that do not contain the key at all. We would lower bloom_filter_fp_chance to 0.01, rewrite the existing SSTables, and fix compaction so each partition lives in fewer SSTables.

Why this question is asked

Read latency that creeps up over weeks is one of the most common Cassandra tickets, and the cause is usually not the hardware but the shape of the data on disk. Interviewers like this question because it checks whether we understand the LSM read path and its Bloom filters well enough to read nodetool output instead of guessing. The overview already gives us three clues: 9 SSTables per read, a false ratio of 0.28, and an fp chance of 0.1. In this answer, we will recap how an LSM engine reads, see exactly what a Bloom filter does on that path, work out why these numbers explain the latency, and then go through the fixes in the order we would apply them.

1A Quick Recap of the LSM Read Path

An LSM engine (log-structured merge tree) never updates data in place. Cassandra writes each change to a commit log and to an in-memory table called the memtable. When the memtable fills, it is flushed to disk as an SSTable, a sorted, immutable file. Over time a table has many SSTables, and a background process called compaction merges them into fewer, larger ones.

So a single partition, which is all rows that share a partition key, can be spread across several SSTables: an insert from last week in one file, an update from yesterday in another, a deletion marker in a third. To answer a read, Cassandra must look at every SSTable that might hold a piece of that partition and merge the pieces by timestamp.

The expensive part is touching disk. Each SSTable that is actually opened costs at least an index lookup and a data block read, so a read that touches nine SSTables does roughly nine times the disk work of one that touches one.

2What the Bloom Filter Does on That Path

A Bloom filter is a compact bit array that answers one question about a key: is it definitely absent, or maybe present? When an SSTable is written, every partition key in it is hashed by several hash functions, and each hash sets one bit. To test a key, we hash it the same way. If any of those bits is zero, the key was never added, so the answer is a certain no. If all bits are one, the key is probably there, but those bits could have been set by other keys, which is a false positive.

Cassandra keeps one Bloom filter per SSTable, off heap in memory. On a read, it checks every SSTable's filter for the requested partition key and opens only the files whose filter says maybe. With good filters and well-compacted data, a point read on a table with, say, 30 SSTables checks 30 filters in memory and reads only the one or two files that really hold the key.

Step throughA partition key read in Cassandra
  1. Read for partition key kcoordinator sends it to a replica
  2. Check memtablein memory
  3. Next SSTable: filter says maybe?
    YesCheck the partition index and read the data blockNoSkip this SSTable, no disk work
  4. Key really in this SSTable?
    YesUseful readNoWasted read: a false positive
  5. Merge the pieces by timestampreturn the newest values

5 steps in order. Play them, or step through them one at a time.

The filter never gives a false no, so correctness never depends on it. It only saves work. That is why its tuning knob is a probability: bloom_filter_fp_chance is the chance that the filter says maybe for a key the SSTable does not contain.

3Reading the Numbers in the Overview

Now we can read the nodetool output. The false ratio in nodetool tablestats is roughly the share of filter answers of maybe that turned out to be wrong, so 0.28 means that more than a quarter of the SSTables we opened did not contain the key. With fp_chance at 0.1, each filter wrongly says maybe for about one absent key in ten. When a table has 30 SSTables and a key lives in only a few of them, the remaining 27 filters each have a 10 percent chance of sending us to disk for nothing, which is almost 3 wasted reads per request on average. Check how your version computes the ratio, but the conclusion is the same: false positives are a real part of the 9 SSTables per read.

The other part is genuine spread. If the median read touches 9 SSTables and a quarter of those are false positives, the partition still really lives in 6 or 7 files, which points at compaction. Notice that 0.1 is the default fp chance for leveled compaction, where a read normally touches very few SSTables, so these filters are tuned for a data layout this table does not have.

So the latency rise from 3 ms to 25 ms has two causes that multiply each other: many SSTables per partition, and filters that are too weak to rule out the SSTables that do not hold the key.

4Fix 1: Stronger Filters and How They Take Effect

The first change is to lower the false positive chance. The bits needed per key grow with the logarithm of the target rate: about 4.8 bits per key at 10 percent and about 9.6 bits per key at 1 percent. So going from 0.1 to 0.01 roughly doubles the filter memory. For a node holding 500 million partitions, that is around 300 MB growing to about 600 MB of off-heap memory, which is usually affordable, but we should check it against the node's free memory before applying it.

SQL
-- CQL
ALTER TABLE shop.account_events WITH bloom_filter_fp_chance = 0.01;
# shell, one node at a time
nodetool upgradesstables -a shop account_events # rewrites every SSTable with the new filter
nodetool tablestats shop.account_events # Bloom filter false ratio should fall toward 0.01

There is a catch: the setting is used when an SSTable is written, so existing files keep their old filters. New flushes and compactions get the stronger filter automatically. To fix the existing files quickly, nodetool upgradesstables with the -a flag rewrites all SSTables even if they are already at the current format, which also rebuilds their filters. That rewrite costs disk IO and free space, so we run it node by node outside peak hours, or simply let normal compaction rewrite the files over days.

5Fix 2: Fewer SSTables per Read

Even perfect filters cannot help when the partition really is in 7 SSTables, because then all 7 must be read. So the second fix is compaction. We look at nodetool compactionstats for pending tasks, at the strategy in the table schema, and at the write pattern. If rows are updated over a long time, leveled compaction keeps each partition in very few SSTables at the cost of more write amplification, which suits a read-heavy table. If compaction is simply behind, we raise compaction throughput or add capacity. If time-window compaction is used, we check that data is written once and not updated across windows.

6Where Bloom Filters Cannot Help

Bloom filters only answer membership of a partition key. A range scan, a query by clustering columns without the partition key, a secondary index query, or anything with ALLOW FILTERING cannot use them, because there is no single key to test. If the slow reads are those kinds of queries, changing fp_chance will not move the latency. In that case the fix is the data model: a table designed for that query, keyed by what the query filters on.

7Follow-up questions

Why not set bloom_filter_fp_chance to 0.0001 everywhere?

Because memory grows with every halving of the error rate, and the benefit shrinks. Going from 1 percent to 0.01 percent roughly doubles the filter size again, while the saving is at most one percent of reads per SSTable. For most tables 0.01 is a good balance; tables with very few SSTables per read can live with 0.1.

How would you confirm the fix worked?

We watch the Bloom filter false ratio in tablestats fall toward the new target as SSTables are rewritten, the SSTables-per-read histogram in tablehistograms drop toward one or two, and the read latency percentiles return toward the earlier 3 ms. Comparing a node that was rewritten with one that was not gives a clean before-and-after picture.

8Conclusion

In this answer, we saw that Cassandra keeps one Bloom filter per SSTable and checks them all before touching disk, so a read opens only the files that might hold the partition key. With fp_chance at 0.1 and reads spread over 9 SSTables, false positives and genuine spread add up to many disk reads per request. We would lower fp_chance to 0.01 and rewrite existing SSTables with nodetool upgradesstables -a or through compaction, fix the compaction strategy or backlog so partitions live in fewer files, and remember that Bloom filters do nothing for range scans or queries without the partition key.

What to say in the interviewAbout 90 seconds aloud

Open with

In an LSM engine like Cassandra, a partition can be spread across many immutable SSTables, so every SSTable has a Bloom filter of its partition keys. A read checks all the filters in memory and only goes to disk for the SSTables whose filter says maybe.

Then, if they want more

With good filters and good compaction, a point read touches one or two files. Here the table uses bloom_filter_fp_chance 0.1, so each filter wrongly says maybe for about ten percent of absent keys, and the measured false ratio of 0.28 tells me more than a quarter of the SSTables we open do not even contain the key.

At the same time the median read touches 9 SSTables, so the partitions are also genuinely spread out. I would do two things.

First, lower fp_chance to 0.01, which costs roughly double the filter memory, about ten bits per key instead of five, and then rewrite existing SSTables with nodetool upgradesstables -a one node at a time, because the setting only applies to newly written files.

Second, look at compaction: pending tasks, the strategy, and whether updates are spread over time; leveled compaction or catching up the backlog brings SSTables per read down, and no filter helps if the data really is in seven files. I would also confirm the slow queries are by partition key, because range scans cannot use Bloom filters at all.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Explain how Bloom filters are used on the read path of an LSM storage engine, why they...": https://scrivio-interview-library.netlify.app/architecture/distributed-systems/27945f1684/