I\'m trying to implement request throttling via the following:
Best way to implement request throttling in ASP.NET MVC?
I\'ve pulled that code into my solut
WebApiThrottle is quite the champ now in this area.
It's super easy to integrate. Just add the following to App_Start\WebApiConfig.cs
:
config.MessageHandlers.Add(new ThrottlingHandler()
{
// Generic rate limit applied to ALL APIs
Policy = new ThrottlePolicy(perSecond: 1, perMinute: 20, perHour: 200)
{
IpThrottling = true,
ClientThrottling = true,
EndpointThrottling = true,
EndpointRules = new Dictionary<string, RateLimits>
{
//Fine tune throttling per specific API here
{ "api/search", new RateLimits { PerSecond = 10, PerMinute = 100, PerHour = 1000 } }
}
},
Repository = new CacheRepository()
});
It's available as a nuget too with the same name.