How harikamasam/distributed-rate-limiter-gateway works
The product is a FastAPI API gateway that authenticates API keys, applies per-tier token-bucket limits, and serves protected API routes. Its principal path is client request → gateway policy → Redis-backed limiter → shared Redis state; accepted requests continue to the demo API routes. The repository also includes an in-memory algorithm implementation, dashboard/stats capability, health check, and documented benchmark. Source excerpts establish gateway and limiter calls; dashboard and benchmark relationships are based on README descriptions.
Main entry points: main.py Gateway middleware · redis_token_bucket.py Redis limiter · index.html Stats dashboard · benchmark.py Load benchmark
Components 10
Gateway
- Gateway middleware
app/main.py - Protected API routes
app/main.py - Tier policy
app/main.py
Rate Limiting
- Redis limiter
app/redis_token_bucket.py - In-memory limiter
app/token_bucket.py - Redis
Operations
- Stats and health API
app/main.py - Stats dashboard
dashboard/index.html - Load benchmark
benchmark.py
Other components
- API client
Connections 9
- API client → Gateway middleware: sends request
README.md - Gateway middleware → Tier policy: checks API key
app/main.py - Gateway middleware → Redis limiter: checks limit
app/main.py - Redis limiter → Redis: runs atomic script
app/redis_token_bucket.py - Gateway middleware → Protected API routes: dispatches allowed
app/main.py - API client → Stats and health API: requests stats
README.md - Stats dashboard → Stats and health API: reads stats
README.md - Stats and health API → Redis: checks health
app/main.py - Load benchmark → Gateway middleware: sends concurrent requests
README.md