Skip to content

Set Rate limiter schema for Routes #1776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Kahbazi opened this issue Jun 25, 2022 · 9 comments · Fixed by #1967
Closed

Set Rate limiter schema for Routes #1776

Kahbazi opened this issue Jun 25, 2022 · 9 comments · Fixed by #1967
Labels
help wanted We will welcome a contribution Type: Idea This issue is a high-level idea for discussion.

Comments

@Kahbazi
Copy link
Member

Kahbazi commented Jun 25, 2022

What should we add or change to make your life better?

The new RateLimiter middleware per endpoint is currently in draft and it is worth being able to set different policy for YARP routes for it when it's merged.

public sealed record RouteConfig
{
+     public string? RateLimiterPolicy { get; init; }
}

  "ReverseProxy": {
    "Routes": {
      "route1" : {
        "ClusterId": "cluster1",
+      "RateLimiterPolicy": "customPolicy",
        "Match": {
          "Hosts": [ "localhost" ]
        },
      }
    },
    "Clusters": {
      "cluster1": {
        "Destinations": {
          "cluster1/destination1": {
            "Address": "https://localhost:10001/"
          }
        }
      }
    }
  }
}

Why is this important to you?

@Kahbazi Kahbazi added the Type: Idea This issue is a high-level idea for discussion. label Jun 25, 2022
@Tratcher
Copy link
Member

Also tracked by dotnet/aspnetcore#37387

@karelz
Copy link
Member

karelz commented Jun 30, 2022

Triage: We need to light up .NET 7.0 feature like this one.

@karelz karelz added this to the YARP 2.0.0 milestone Jun 30, 2022
@karelz karelz added this to YARP 2.x Jun 30, 2022
@Tratcher
Copy link
Member

@Tratcher Tratcher added the help wanted We will welcome a contribution label Aug 19, 2022
@Tratcher
Copy link
Member

@Kahbazi want to try this now? It should be almost a copy of the auth feature.

@Kahbazi
Copy link
Member Author

Kahbazi commented Aug 19, 2022

@Tratcher Yes I will take this one.

@Kahbazi
Copy link
Member Author

Kahbazi commented Aug 20, 2022

Ok! I started to implement this and I hit some design issues. RateLimitingMiddleware is not in the ASP.Net Core framework. It has its own nuget package. What is the approach here?

  1. Add reference to Microsoft.AspNetCore.RateLimiting in YARP. This is an easy but maybe not so good solution.
  2. Create a new package Microsoft.ReverseProxy.RateLimiting. This would have reference to the middleware but then extending RouteInfo (Design: Richer Extensibility for routes and clusters #1796) might be challenging.

@Tratcher
Copy link
Member

It should be in the framework for rc1. You'll need a current runtime/SDK dependency to try that.
dotnet/aspnetcore@9d4537c

@mburumaxwell
Copy link
Contributor

Are contributions still being accepted for this or has it already been implemented?

@Tratcher
Copy link
Member

@mburumaxwell It's still available, go ahead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We will welcome a contribution Type: Idea This issue is a high-level idea for discussion.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants