AICentral.RateLimiting.DistributedRedis
0.20.5
dotnet add package AICentral.RateLimiting.DistributedRedis --version 0.20.5
NuGet\Install-Package AICentral.RateLimiting.DistributedRedis -Version 0.20.5
<PackageReference Include="AICentral.RateLimiting.DistributedRedis" Version="0.20.5" />
paket add AICentral.RateLimiting.DistributedRedis --version 0.20.5
#r "nuget: AICentral.RateLimiting.DistributedRedis, 0.20.5"
// Install AICentral.RateLimiting.DistributedRedis as a Cake Addin #addin nuget:?package=AICentral.RateLimiting.DistributedRedis&version=0.20.5 // Install AICentral.RateLimiting.DistributedRedis as a Cake Tool #tool nuget:?package=AICentral.RateLimiting.DistributedRedis&version=0.20.5
AICentral.RateLimiting.DistributedRedis
A Distributed Rate Limiter for use with (AICentral)[www.github.com/microsoft/aicentral]
Configuration
dotnet add package AICentral.RateLimiting.DistributedRedis
builder.Services.AddAICentral(
builder.Configuration,
additionalComponentAssemblies:
[
typeof(DistributedRateLimiter).Assembly,
]);
{
"AICentral": {
"GenericSteps": [
{
"Type": "DistributedRateLimiter",
"Name": "request-rate-limiter",
"Properties": {
"LimitType": "PerEndpoint|PerConsumer",
"MetricType": "Tokens|Requests",
"Window": "00:00:10",
"PermitLimit": 100,
"RedisConfiguration" : "<Redis connection string>"
}
}
]
}
}
How does it work?
For each pipeline a Redis Key is constructed which will identify this pipeline (optionally and the client) across AICentral Instances. We store a Hash against this Redis key which is the current count of requests or tokens used.
Importantly the Hash Key contains a value derived from a Static point in time and the window information. This means the Key will always be the same across instances.
The Rate Limiter checks the sum of all the Hashes for the current window and if it is greater than the limit then the request is rejected. The key automatically changes as we enter a new window meaning the totals are reset.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- AICentral.Core (>= 0.20.3)
- Aspire.StackExchange.Redis (>= 8.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.