stefanprodan / WebApiThrottle

ASP.NET Web API rate limiter for IIS and Owin hosting
MIT License
1.28k stars 275 forks source link

Rate Limit on excessive errors #153

Open jasenf opened 1 year ago

jasenf commented 1 year ago

Hi,

We have a number of customers who build out client apps to our API and leave unattended for long periods of time. Eventually their calls become problematic for one reason or another and start returning useless data (ex: searching continuously for an item that has been deleted and the search should have stopped.). This is a drain on our database resources and we would like to conditionally rate limit these API calls once a certain threshold of "invalid" calls are mades.

In most cases where this is happening, we catch them with internal customized exceptions (customer doesn't see the exception of course). We would like to use the exception handler to start throttling specific users when the exception count reaches some value. So, if a specific IP address makes a call to our API that is throwing an internal exception 10 times within 5 minutes, we would like to throttle them back and restrict them from making any more calls for the next 20 minutes.

Can WebApiThrottle be extended to easily do this?