The repository ships with a ready-to-useDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nimanikoo/Dotnet-RateLimiter/llms.txt
Use this file to discover all available pages before exploring further.
compose.yaml and a multi-stage Dockerfile that together spin up the entire Dotnet-RateLimiter infrastructure with a single command. The stack includes three services — the .NET 10 API, a Redis instance, and the RedisInsight monitoring UI — all wired together on a private bridge network. No manual configuration is required to get started locally.
Docker Compose Configuration
The fullcompose.yaml from the repository:
api service uses Redis__ConnectionString=redis:6379,abortConnect=false — the double-underscore notation maps to the Redis:ConnectionString key in appsettings.json, overriding it with the Docker-internal hostname redis (the service name) instead of localhost. This is how the API container resolves Redis within the shared ratelimit-network.
Dockerfile
The application is built using a 4-stage Docker build for a minimal, optimized final image:| Stage | Base Image | Purpose |
|---|---|---|
base | mcr.microsoft.com/dotnet/aspnet:10.0 | Lightweight runtime-only image; exposes ports 8080 and 8081 |
build | mcr.microsoft.com/dotnet/sdk:10.0 | Restores NuGet packages and compiles the project in Release mode |
publish | inherits build | Publishes the self-contained output to /app/publish with UseAppHost=false |
final | inherits base | Copies only the published output into the slim runtime image |
Running the Stack
Build and start all services
Run the full stack in detached mode. Docker Compose will build the API image, pull The
redis:alpine and redislabs/redisinsight:latest, and start all three containers:depends_on directives ensure Redis starts before the API and RedisInsight containers attempt to connect. Watch the logs to confirm all services are healthy:Access the running services
Once the stack is up, all three services are reachable on
To connect RedisInsight to the running Redis instance, use:
localhost:| Service | URL | Description |
|---|---|---|
| API | http://localhost:8080 | ASP.NET Core 10 rate limiter API |
| Swagger UI | http://localhost:8080/swagger | Interactive OpenAPI documentation (Development only) |
| Health Dashboard | http://localhost:8080/health-ui | Real-time health checks for Redis and the .NET runtime |
| Health Endpoint | http://localhost:8080/health | Raw JSON health check output |
| RedisInsight UI | http://localhost:8001 | Visual Redis browser and key inspector |
- Host:
redis - Port:
6379
rate_limit:* keys appear in real time as requests are processed, observe their counters, and monitor their TTL countdown.Environment Variables
Theapi service accepts the following environment variables, set in compose.yaml or overridden at runtime:
| Variable | Default (compose.yaml) | Description |
|---|---|---|
ASPNETCORE_ENVIRONMENT | Development | Controls environment-specific behavior. Development enables Swagger UI and verbose logging. |
Redis__ConnectionString | redis:6379,abortConnect=false | The StackExchange.Redis connection string. The double-underscore maps to the Redis:ConnectionString configuration key. Inside the Docker network, use the service name redis as the hostname. |
Docker Network
All three services (redis, api, redis-insight) are attached to the ratelimit-network bridge network defined at the bottom of compose.yaml:
redis by the service name), while isolating the stack from other Docker workloads on the host. Only the explicitly published ports (6379, 8080, 8001) are accessible from outside the network.
For production deployments: Replace the
redis:alpine service with a managed Redis offering (such as Azure Cache for Redis, AWS ElastiCache, or Redis Cloud) and update the Redis__ConnectionString environment variable on the api service to point to the managed instance’s connection string. Remove the local redis and redis-insight service definitions from compose.yaml — RedisInsight is a development tool and should not be exposed in production. Ensure the managed Redis instance is accessible from your container host and that TLS is enabled on the connection string if required by your provider.