{"id":25522246,"url":"https://github.com/dotnet-labs/semaphoreslimthrottle","last_synced_at":"2025-07-07T06:34:33.088Z","repository":{"id":108781466,"uuid":"278359962","full_name":"dotnet-labs/SemaphoreSlimThrottle","owner":"dotnet-labs","description":"Rate Limiting API Endpoints in ASP.NET Core","archived":false,"fork":false,"pushed_at":"2021-03-13T03:27:37.000Z","size":20,"stargazers_count":20,"open_issues_count":0,"forks_count":8,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-11T01:39:52.833Z","etag":null,"topics":["api","asp-net-core","aspnetcore","concurrency","concurrent","dotnet","dotnet-core","dotnetcore","http","http-client","http-request","httpclient","rate-limiting","semaphore","throttle","throttling"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotnet-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"changhuixu","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2020-07-09T12:34:56.000Z","updated_at":"2023-02-06T15:16:44.000Z","dependencies_parsed_at":"2023-06-05T01:00:30.566Z","dependency_job_id":null,"html_url":"https://github.com/dotnet-labs/SemaphoreSlimThrottle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dotnet-labs/SemaphoreSlimThrottle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FSemaphoreSlimThrottle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FSemaphoreSlimThrottle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FSemaphoreSlimThrottle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FSemaphoreSlimThrottle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotnet-labs","download_url":"https://codeload.github.com/dotnet-labs/SemaphoreSlimThrottle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnet-labs%2FSemaphoreSlimThrottle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264028241,"owners_count":23546205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","asp-net-core","aspnetcore","concurrency","concurrent","dotnet","dotnet-core","dotnetcore","http","http-client","http-request","httpclient","rate-limiting","semaphore","throttle","throttling"],"created_at":"2025-02-19T18:18:55.382Z","updated_at":"2025-07-07T06:34:33.081Z","avatar_url":"https://github.com/dotnet-labs.png","language":"C#","funding_links":["https://ko-fi.com/changhuixu","https://ko-fi.com/changhuixu'"],"categories":[],"sub_categories":[],"readme":"# Rate Limiting API Endpoints in ASP.NET Core\n\n\u003ca href='https://ko-fi.com/changhuixu' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi3.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n\n## [Medium Post 1: Rate Limiting API Endpoints in ASP.NET Core](https://medium.com/@changhuixu/rate-limiting-api-endpoints-in-asp-net-core-926e31428017)\n\nThis post shows (1) an ASP.NET Core Web API demo project which limits inbound HTTP requests from the internet and (2) an integration test project which tests the Web API rate limit using a `TestServer` and an `HttpClient`. One of the integration tests shows an example approach to send concurrent API requests using a `Semaphore` in order to comply with the rate limit in the Web API application.\n\n## [Medium Post 2: Throttling Concurrent Outgoing HTTP Requests in .NET Core](https://medium.com/@changhuixu/throttling-concurrent-outgoing-http-requests-in-net-core-404b5acd987b)\n\nThis post will go over how to make concurrent outgoing HTTP requests _on the client side_. The goal is to let the HTTP Client send concurrent requests at the maximum allowed rate which is set by the server, for example, at a maximum rate of 2 requests per second.\n\n## Solution Structure\n\nThis solution contains 3 projects.\n\n1 `ThrottledWebApi`\n\n- An ASP.NET Core Web API project\n- Contains one API endpoint: `/api/values/isPrime?number={number}`\n- The API endpoint is enforced with rate limit\n\n2 `ThrottledWebApi.IntegrationTests`\n\n- An integration test project with an in-memory test server\n- An HTTP client is used to test against the API endpoint\n- The rate limiting effect in different scenarios are tested\n\n3 `ThrottledWebApi.ClientDemo`\n\n- A .NET Core Console app with Dependency Injection, HttpClient\n- Throttling concurrent outgoing HTTP requests using a `semaphore`\n\n## License\n\nFeel free to use the code in this repository as it is under MIT license.\n\n\u003ca href='https://ko-fi.com/changhuixu' target='_blank'\u003e\u003cimg height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi3.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-labs%2Fsemaphoreslimthrottle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnet-labs%2Fsemaphoreslimthrottle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnet-labs%2Fsemaphoreslimthrottle/lists"}