- Bloom Filters
- Changing
Bloom Filters
In the read path, Cassandra merges data on disk (in SSTables) with data in RAM (in memtables). To avoid checking every SSTable data file for the partition being requested, Cassandra employs a data structure known as a bloom filter. Bloom filters are a probabilistic data structure that allows Cassandra to determine one of two possible states: - The data definitely does not exist in the given file, or - The data probably exists in the given file.bloom_filter_fp_chanceto a float between 0 and 1.bloom_filter_fp_chanceis 0.1 for tables using LeveledCompactionStrategy and 0.01 for all other cases.bloom_filter_fp_chancegets closer to 0), memory usage increases non-linearly - the bloom filter forbloom_filter_fp_chance = 0.01will require about three times as much memory as the same table withbloom_filter_fp_chance = 0.1.bloom_filter_fp_chanceare usually between 0.01 (1%) to 0.1 (10%) false-positive chance, where Cassandra may scan an SSTable for a row, only to find that it does not exist on the disk. The parameter should be tuned by use case: bloom_filter_fp_chanceto a numerically lower number (such as 0.01) to avoid excess IO operationsbloom_filter_fp_chancein order to save RAM at the expense of excess IO operationsbloom_filter_fp_chanceto a much higher number is acceptable.Changing
DESCRIBE TABLEoutput as the fieldbloom_filter_fp_chance. Operators can change the value with anALTER TABLEstatement: :ALTER TABLE keyspace.table WITH bloom_filter_fp_chance=0.01
ALTER TABLEstatement, new files on disk will be written with the newbloom_filter_fp_chance, but existing sstables will not be modified until they are compacted - if an operator needs a change tobloom_filter_fp_chanceto take effect, they can trigger an SSTable rewrite usingnodetool scrubornodetool upgradesstables -a, both of which will rebuild the sstables on disk, regenerating the bloom filters in the progress.
