Hacker News new | ask | show | jobs
by Xeoncross 6 days ago
I've never liked token buckets (vs sliding window counters) due to the extra work CPU cycles required to "fill" them. It seems like doing an atomic incr on a key based on a `time % 1 minute` or something would be more efficient and then let that key TTL expire X duration later. This results in zero work for rate limiters not in use and only a single push change -> resulting count for ones in use. Nothing but setting the TTL extra is required.

Thanks for the links, I'll checkout the Generic Cell Rate Algorithm!