Skip to main content

Documentation 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.

The compose.yaml in Dotnet-RateLimiter bundles a RedisInsight container alongside the API and Redis services. RedisInsight is a GUI that lets you browse keys, inspect values, and watch TTL countdowns in real time — making it the fastest way to verify that your Lua-based rate limiter is writing keys correctly and that they expire on schedule.

Accessing RedisInsight

Once the stack is running (docker compose up), open your browser to:
http://localhost:8001
When prompted to connect to a Redis database, use the internal Docker network hostname rather than localhost:
FieldValue
Hostredis
Port6379
The redis-insight container is on the same ratelimit-network bridge network as the redis container, so the hostname redis resolves correctly without any extra DNS configuration.

Docker Compose Configuration

The redis-insight service is defined in compose.yaml as follows:
redis-insight:
  image: redislabs/redisinsight:latest
  container_name: redis-insight
  ports:
    - "8001:8001"
  depends_on:
    - redis
  networks:
    - ratelimit-network

networks:
  ratelimit-network:
    driver: bridge
The depends_on: redis directive ensures RedisInsight only starts after the Redis container is ready, and the shared ratelimit-network bridge lets it resolve the redis hostname directly.

What You Can Inspect

Rate limit keys created in real time

Every request that passes through RedisRateLimitingMiddleware causes the Lua script to call INCR on a key with the following naming pattern:
rate_limit:{userType}:{identityKey}:{path}
For example, an authenticated user with ID user-123 hitting /api/weather produces:
rate_limit:user:user-123:/api/weather
An anonymous guest from IP 192.168.1.10 produces:
rate_limit:guest:192.168.1.10:/api/weather
In the RedisInsight key browser you will see these keys appear the moment the first request arrives.

TTL countdown

Select any rate_limit:* key in RedisInsight and switch to the TTL view. You can watch the remaining seconds tick down in real time. When the window closes, the key disappears automatically and the counter resets for the next window.

Counter values

The value stored at each key is a plain integer set by Redis’s INCR command. Clicking a key shows the current count — for example 3 means the identity has made 3 requests in the current window. Once the count exceeds maxRequests, the Lua script returns 0 and the middleware responds with HTTP 429.

Key expiry

Keys are given a TTL by the Lua EXPIRE call on the first INCR (when the counter transitions from 0 to 1). When the TTL reaches 0, Redis deletes the key automatically. You can verify this in the Key expiry column of the key browser — no manual cleanup is required.

Practical Use Cases

  • Debug why a specific user is being rate-limited — search for rate_limit:user:<userId>:* and check the current counter value against the MaxRequests configured on the [RedisRateLimit] attribute.
  • Verify correct key naming — confirm that authenticated requests produce user: prefixed keys and anonymous requests produce guest: prefixed keys, matching the logic in RedisRateLimitingMiddleware.
  • Monitor Redis memory usage — use the RedisInsight memory analysis tab to measure how many bytes rate limit keys consume, especially under high-traffic conditions where many unique identities are active simultaneously.

After starting the stack with docker compose up, send several rapid requests to a rate-limited endpoint (for example, hit GET /api/weather five times in quick succession). Switch to the RedisInsight key browser and watch the integer counter increment live with each request. When it exceeds the MaxRequests limit, your next request will receive a 429 — and you can see exactly why from the counter value in RedisInsight.

Build docs developers (and LLMs) love