Skip to main content

Counting with Less

Count-Min Sketch is a beautiful data structure. It’s relatively young, first described by Cormode and Muthukrishnan in 2003. I came across this algorithm while looking at rate limiting strategies, and the core idea is so clever that I wanted to build something interactive around it.

I promise there is very little math needed to follow along.

We’re in our everything-is-a-bottleneck era. Traffic volumes have never been higher, and compute/memory has never been harder to come by. AI agents are using more and more of those resources, both directly via inference/training and through API calls on behalf of their handlers. I think probabilistic data structures like the count-min sketch will be increasingly important for building efficient systems that can handle higher volumes of data. And they also lean into the non-exact, non-deterministic nature of these systems, which is fun to learn about. It’s simple to expect exact answers from our data structures, but in many cases an estimate is good enough, and can be obtained much cheaper.

Counting with Less using Count-Min Sketch