Obvs icon indicating copy to clipboard operation
Obvs copied to clipboard

How to use Hammer to count the number of times rate-limits are reached within an interval

Open egeersoz opened this issue 1 year ago • 3 comments

Not a bug per se, I just wanted to see if anyone had thoughts.

We started using Hammer to deal with some spammers who have been using our app to send lots of emails. It works well so far, as in the amount of damage spammers cause is now limited (e.g. each IP address can now send X emails per minute, after which they get 429'd).

We want to take this one step further though, by adding an IP address to a blacklist if requests coming from it are rate-limited more than X times within a given interval Y. In other words, it's like rate-limiting, but at a "meta" level.

Is there a way to utilize Hammer for this purpose?

egeersoz avatar Jan 04 '24 17:01 egeersoz

👋 @egeersoz

An easy way would be to check the limit for the Y * X bucket, it wouldn't be a sliding window though.

ruslandoga avatar Jan 04 '24 22:01 ruslandoga

we don t have anything like that. You would need to do what @ruslandoga suggests or you can create dynamic bucket and check 2 of them in the same time based on conditions you need?

epinault avatar Jan 09 '24 16:01 epinault

We want to take this one step further though, by adding an IP address to a blacklist if requests coming from it are rate-limited more than X times within a given interval Y. In other words, it's like rate-limiting, but at a "meta" level.

My two cents: have a separate bucket with limit X for interval Y and blacklist when that limit is exceeded.

Trying to use one bucket for two different limits and timescales is a lot of complexity

njwest avatar Jul 21 '24 16:07 njwest