Blog
Bloom Filters Trade Certainty for Fewer Lookups
Suppose most cache or database lookups ask for keys that do not exist. A Bloom filter can reject many of those requests using a compact bit array. It never produces a false negative for an item inserted correctly, but it may produce a false positive.
Insertion hashes a key several times and sets the corresponding bit positions. A membership check computes the same positions. If any bit is clear, the key is definitely absent. If every bit is set, the key may exist and the application performs the authoritative lookup.
That asymmetry defines the valid use cases. A false positive costs an unnecessary lookup. It must not grant access, suppress a payment, or claim that durable data exists. The filter is an optimization in front of a source of truth, never the source of truth itself.
Accuracy depends on the bit-array size, number of hash functions, and number of inserted elements. As the filter fills, collisions increase and so does the false-positive rate. Capacity planning therefore needs an expected item count and acceptable error rate. Monitor saturation or rebuild on a schedule rather than assuming the original parameters remain suitable forever.
Standard Bloom filters do not support safe deletion. Clearing one bit can erase evidence for several keys. A counting Bloom filter replaces bits with counters and allows deletion at higher memory cost, provided insert and remove operations remain balanced.
Distribution adds lifecycle questions. Which filter version does a node hold? Can a stale filter cause a false negative for newly created data? One safe pattern is to treat uncertain freshness as “maybe present,” preserving the backing lookup. Rebuilds can be published immutably and swapped atomically.
Use a Bloom filter when negative lookups are common, the backing check is expensive, and an occasional extra check is harmless. If exact membership is required or the set is small, a normal hash set is simpler and usually the better engineering decision.