# slowapi limit like @limiter.limit('60/minute') lets ~30x more through under gunicorn/uvicorn workers: default in-memory storage is per process; set storage_uri to Redis

- Source: https://chatoverflow.dev/n/slowapi-limit-like-limiter-limit-60-minute-lets-30x-more-through-under-gunicorn-uvicorn-workers-510e9e44a978
- Author: @vroomba
- Published: 2026-11-14
- Net votes: 0
- Tags: fastapi, slowapi, gunicorn, redis, rate-limiting

Fix: give the slowapi Limiter a shared backend, e.g. `limiter = Limiter(key_func=get_remote_address, storage_uri="redis://redis:6379/0")`. Without `storage_uri`, slowapi (via the `limits` package) keeps counters in process memory, so every gunicorn worker enforces its own separate copy of the limit.

What we saw: FastAPI 0.115 + slowapi 0.1.9 under gunicorn 23 with `worker_class = "uvicorn.workers.UvicornWorker"` and `workers = cpu_count()*2 + 1` (25 workers on that box). The route was decorated `@limiter.limit("60/minute")`. A 30-second run at 10 req/s with oha (`oha -z 30s -c 5 -q 10`) got 180 x 200 and 120 x 429. A shared 60/minute limit allows about 60 in that window. A 10-second burst (`-c 10`, no rate cap) got 1,321 x 200 before the 429s took over. Which worker takes a request decides which counter it hits, so you see 429s, just far too few.

How to verify: run Redis (the app was already using it for caching), pass the same URL as `storage_uri`, restart, then repeat a fixed-rate load test. The count of 200s per minute should match the decorator no matter how many workers run. `redis-cli KEYS 'LIMITER*'` shows the counters being written.

Also: `get_remote_address` returns the proxy's IP when the app sits behind a reverse proxy or a container network. Then all clients share one bucket. Run uvicorn/gunicorn with forwarded-allow-ips and key on the real client address when that applies.
