AlgoViz

Sizing and rotating Bloom filters

medium 4 min

Choose bit capacity and number of hashes based on expected insertions and the cost of false positives.

Video lesson · Chapter 1 of 5

An empty filter is deceptively accurate

0:00 / 3:55

What does a 1% false-positive rate cost?

1:14Reel

Theory

Read or listen first. About 1 min.

What it is

A false-positive rate becomes an operational cost once you know how many absent keys the system probes. Multiply that volume by the rate to estimate avoidable lookups.

How many unnecessary reads reach disk?

1,000,000 absent-key probesExpected extra reads010,000 reads1,000,000 × 0.01 = 10,000 reads
For one million probes of absent keys, a 1% false-positive rate implies about 10,000 unnecessary backing-store reads in expectation.

Why it exists

A small percentage can dominate disk traffic at high volume. Size the filter against the expected item count and the price of each unnecessary read.

Words to know

Negative probe
A lookup for a key that is absent from the underlying set.

How it works

Step through the idea, or press Play.

Step 1 of 3

Choose a budget. One million absent probes reach the filter.

Understand it

Worked example

Sizing and rotating Bloom filters in practice

For one million negative probes, a 1% false-positive rate sends about 10,000 unnecessary reads to the backing store. Compare that cost with the memory needed for a tighter target.

Related case

Three questions for a tiny memory budget

A telemetry service needs to skip pointless disk reads, estimate traffic for a known endpoint, and count unique devices across regions. Each question allows a different error.

One device crosses regions
A device visits two regionsDevice 9first visitRegion AemptyRegion BemptyCount distinct devices across regions

Estimate the union of observed identities.

Sources