stefanprodan / WebApiThrottle

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

Question: Multiple Throttling-policies #55

Closed phillikus closed 8 years ago

phillikus commented 8 years ago

Is it possible to have multiple throttling-policies at the same time?

For example I want to add a generic throttling to two policies:

1.) ClientThrottling which limits all requests independent of the route so that one user can only perform lets say 30 requests per second in total.

2.) ClientThrottling + EndpointThrottling: Limit the number of requests / second for each endpoint to 5 requests per second.

The goal is to allow the user to perform 'many' different requests at the same time while at the same time preventing him from spamming a single route.

As far as I see this is only possible by adding two ThrottlingHandlers at the same time.

As soon as you enable EndpointThrottling there won´t be any throttling when you 'spam' different routes, right?

Please let me know if this is the best approach to achieve what I want or if I am missing something. If there are no big drawbacks to the approach of using two ThrottlingHandlers at the same time, I will go for that approach.

stefanprodan commented 8 years ago

This can't be done with the current implementation, I'm addressing this in the rate limiting middleware for .Net Core https://github.com/stefanprodan/KestrelRateLimit

phillikus commented 8 years ago

Thanks for the response. Looking forward to test out the KestrelRateLimit :) For now I went with the solution I proposed above (adding two ThrottlingHandlers) which works perfectly fine (despite the overhead)

stefanprodan commented 8 years ago

KestrelRateLimit first beta is out, I would appreciate if you would give it a try. Any feedback is welcome.

Thanks