https://github.com/danielmackay/dotnet-rate-limiting
https://github.com/danielmackay/dotnet-rate-limiting
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/danielmackay/dotnet-rate-limiting
- Owner: danielmackay
- Created: 2022-11-09T11:23:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-09T11:29:24.000Z (over 3 years ago)
- Last Synced: 2025-11-27T22:42:50.550Z (8 months ago)
- Language: C#
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# .NET 7 Rate Limiter
## Setup
Install .NET 7
`winget install Microsoft.DotNet.SDK.6`
Install K6
`winget install k6`
## Run
```ps1
cd src
dotnet run
```
## Test
```ps1
cd test
k6 run .\script.js
```
The script sends 1 request per second. The rate limiter allows 4 requests per 12 seconds. As the test runs for 24 seconds we see 8 sucessful requests and 16 failed requests. This gives 33% success and 66% failure as shown by K6:

## Resources
[Microsoft Docs | Rate Limiting](https://learn.microsoft.com/en-us/aspnet/core/performance/rate-limit?view=aspnetcore-7.0)