How does the configured false positive rate affect both the accuracy and the memory usage of a Bloom filter?
Short answer
A lower configured false positive rate makes the Bloom filter more accurate at correctly identifying items that were never actually added, but requires more memory to achieve that higher accuracy, meaning you need to balance your specific application's tolerance for occasional…
Advertisement
AModel answer
A lower configured false positive rate makes the Bloom filter more accurate at correctly identifying items that were never actually added, but requires more memory to achieve that higher accuracy, meaning you need to balance your specific application's tolerance for occasional false positives against how much memory you are willing to allocate to the filter.
Example
BF.RESERVE my_filter 0.001 1000000 -- 0.001 is the desired false positive rate -- 1000000 is the expected number of items
Real-world example
A fraud detection system configures a very low false positive rate for their Bloom filter checking known fraudulent account identifiers, accepting the higher memory cost since incorrectly flagging a legitimate account as fraudulent would be costly.
Likely follow-ups
- What is a reasonable false positive rate for a typical caching or deduplication use case?
- How do you estimate the expected number of items in advance to properly size the filter?
Related topics