Imagine a web server logging millions of requests per second. You want to know: how many errors occurred in the last five minutes? Storing every timestamp is impractical — the stream never ends, and memory is finite.
This is the sliding-window counting problem: maintain a count of events that arrived within the last time steps, using as little memory as possible, while answering queries at any moment.
The naive solution keeps a list of all recent timestamps. It is exact, but it uses space — and can be enormous. Can we do better? In 2002, Datar, Gionis, Indyk, and Motwani showed the answer is yes: you can count within a factor of the true count using only bits of space. The key idea is the exponential histogram — a summary that groups events into exponentially-growing buckets instead of remembering each one.
Comments
Loading comments...