In my perpetual quest for allocationless datastructures, this bloombucket
attempts to rate limit an arbitrary number of peers during initiation. It
works on a mix of a bloom filter and a token bucket, and has configurable
parameters for size and number of hashes. The hashes are kept independent
by using unique siphash keys.
The idea is that a unique input, in this case the peer ip will be hashed
into multiple buckets, and each of those buckets incremented. When
evaluating if a packet should be rate limited, it sees if at least one of
those buckets is not at the threshold. I don't have any good mathematical
notes behind this, but will need to sit down and do some tests to get some
sane defaults for the values.