dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
34.9k stars 9.86k forks source link

Rate limiting / whitelist / change value per Partition key #50391

Open closte opened 11 months ago

closte commented 11 months ago

I just want to know if the following use cases are possible or will be possible in the near future.

Let's say we have rate limiting per IP address.

Use case 1: Is it possible to whitelist the IP/Partition key Use case 2: Is it possible to change the rate limit value per IP/Partition key

Real-life use cases:

I want to whitelist an IP address I want to increase the rate limit for specific IP address or virtual host

tarekgh commented 11 months ago

Are you asking generic questions regarding machine configuration? Or your question related to .NET product?

closte commented 11 months ago

Are you asking generic questions regarding machine configuration? Or your question related to .NET product?

Nope.

.NET has a built-in rate-limiting feature, so how do we whitelist some Partition keys or change the limit value for one or more Partition keys?

Example:

  1. rate limit 60 concurrent connections per IP
  2. whitelist 1.1.1.1
  3. Increase the limit to 100 connections for 2.2.2.2 and 3.3.3.3
ghost commented 11 months ago

Tagging subscribers to this area: @dotnet/ncl See info in area-owners.md if you want to be subscribed.

Issue Details
I just want to know if the following use cases are possible or will be possible in the near future. Let's say we have rate limiting per IP address. > Use case 1: Is it possible to whitelist the IP/Partition key > Use case 2: Is it possible to change the rate limit value per IP/Partition key Real-life use cases: > I want to whitelist an IP address > I want to increase the rate limit for specific IP address or virtual host
Author: closte
Assignees: -
Labels: `question`, `area-System.Net.Http`, `untriaged`, `Team:Libraries`, `needs-area-label`
Milestone: -
rzikm commented 11 months ago

This feels more like a question for ASP.NET folks, since the system libraries don't implement any rate limiting AFAIK.

Edit: I may have been wrong, I found this blog post which talks about it: https://devblogs.microsoft.com/dotnet/announcing-rate-limiting-for-dotnet/

While the scenario you describe is not directly suppoted, you can probably inherit from PartitionedRateLimiter<int> and implement your custom logic there.

karelz commented 11 months ago

@BrennanConroy do you have any insight here?