.net-corerate-limitingms-yarp

Is there any solution in yarp gateway to have a global ratelimiter in .NET Core?


I have a cluster in k8s with 3 replicas of my gateway which is yarp.

I have to set a rate limit in my routes in each replica.

I searched on the internet and I found a solution in yarp for rate limit which is for local traffics not global something like this :

builder.Services.AddRateLimiter(_ => _
    .AddFixedWindowLimiter(policyName: "FixedRateLimiter", options =>
    {
        options.Window = TimeSpan.FromSeconds(12);
        options.PermitLimit = 4;
        options.QueueProcessingOrder = QueueProcessingOrder.OldestFirst;
        options.QueueLimit = 2;
    }));

My question is how can I customize this ratelimiter option in my code to use a distributed cache not in memory storage?


Solution

  • The best solution that I found :

    https://github.com/cristipufu/aspnetcore-redis-rate-limiting