Replies: 2 comments 9 replies
-
@sebastienros or @danroth27 maybe? I'd like to understand if it's a user issue (highly likely) or a missing feature 😄 |
Beta Was this translation helpful? Give feedback.
-
Maybe I'm misunderstanding, but how does a chained limiter solve this? It seems like you want to return a different rate limiter depending on dynamic data. You can achieve this by changing the name of the partition and returning different settings in the new limiter: var dynamicData = 0;
if (dynamicData < 1)
{
return RateLimitPartition.GetNoLimiter("noop");
}
else if (dynamicData < 5)
{
return RateLimitPartition.GetConcurrencyLimiter("stricter", c =>
{
return new ConcurrencyLimiterOptions()
{
PermitLimit = 1000,
QueueLimit = 100
};
});
}
else
{
return RateLimitPartition.GetConcurrencyLimiter("strictest", c =>
{
return new ConcurrencyLimiterOptions()
{
PermitLimit = 100,
QueueLimit = 10
};
});
}
This is also weird and maybe a misunderstanding, why are you trying to apply all policies to all endpoints? If one endpoint is cheap, apply the cheap policy to it. If an endpoint is expensive, apply the expensive policy to it. app.MapGet("/one", () => { }).RequireRateLimiting("cheap");
app.MapGet("/two", () => { }).RequireRateLimiting("expensive"); |
Beta Was this translation helpful? Give feedback.
-
I was following the rate limiting docs https://learn.microsoft.com/en-us/aspnet/core/performance/rate-limit?view=aspnetcore-8.0#create-chained-limiters which allows to create a
GlobalLimiter
in a chained way.I'm missing this on policy level, or is there a way that I might have overlooked?
I would have expected something like this to work
My scenario is the following:
Existing application with lots of endpoints I don't want to enforce a global rate limit immediately since a reasonable default isn't known yet. Therefore I'd like to start lax and make the limits stricter once the load patter per policy is more clear.
Also note that in our case we have/want to distinguish certain workloads via policy because not all endpoints are treated equal e.g. authenticate/non-authenticated and post/get traffic
Beta Was this translation helpful? Give feedback.
All reactions