Sizing and rotating Bloom filters 00:00:01 An empty filter is deceptively accurate One million distinct identifiers arrive in an epoch. A Bloom filter should spare the database most lookups for missing identifiers. Before buying memory, work backward from the allowed unnecessary reads. Suppose a single filter should give a false positive on about one percent of queries for absent keys under the design model. A positive is always confirmed against exact records. The real risk isn't just the rate—it's how often we're asked about IDs that don't exist, which depends on our traffic pattern. At twenty thousand known-absent lookups per minute, a one-percent false-positive rate implies about two hundred unnecessary exact reads per minute on average. That expectation is a capacity input. It does not promise exactly two hundred mistakes in every minute. 00:00:48 Select a bit and hash budget For an ordinary Bloom filter with near-optimal hashes, the bits per item are the negative natural logarithm of the target error divided by the square of the natural logarithm of two. At one percent that is about nine point six bits per item. One million distinct items need about nine point six million bits, or one point two decimal megabytes of raw bit storage. The hash count near the optimum is bits per item times the natural logarithm of two. Here that is about six point six, so choose seven hash selections and check the actual rate. These are decimal megabytes. Divide bits by eight to get bytes, then divide by one million. A real implementation can allocate blocks, headers, and metadata, so check the actual allocated size as well. 00:01:35 Check units and overload the design The sized capacity is a workload assumption. Check the distinct insertions per epoch, the fraction of set bits, and how the exact backing store handles possible positives. If we insert far more than a million distinct keys, we’ll set more bits and the false-positive rate will rise sharply. Duplicate inserts don't harm the filter—they just set the same bit positions again, so no new information is added. At fixed memory, doubling the distinct set increases occupancy and false positives. Watching only event rate can hide this change because a million events from one identifier and a million distinct identifiers fill the filter very differently. 00:02:15 Rotate a time window Now keep a current filter and a previous filter so recent identifiers survive rotation. Insert into the current one. An identifier in either epoch should be treated as possibly present. To rule a key out across both epochs, both filters must report absence. One positive in either filter requires the exact check even if the other filter reports absence. That union increases the possible false-positive rate on an identifier absent from both. The exact combined probability depends on the dependence between their false-positive events. If both filters independently give a one-percent error on an absent key, the union error is one minus point nine nine squared, or about one point nine nine percent. Without independence, a union bound still caps it at their summed error rates. 00:03:03 Verify on known-absent probes If the combined budget is one percent, allocating at most half a percent per filter is one conservative split under the union bound. Size each active filter for its own distinct capacity at that tighter rate. We monitor how full the filter gets and run known-absent probes to catch any drift in false-positive behavior. The operator can now connect a memory purchase to a database cost. Track the combined false-positive traffic and the full two-filter memory footprint through rotation, then resize on observed distinct growth. Choose a query policy at the time boundary. Two fixed epochs approximate a lookback interval; they do not exactly represent the last sixty minutes at every instant. If an exact expiration boundary matters, store time-bearing evidence.