Skip to content

fix: add Postgres-backed rate limiter for multi-worker deployments#222

Merged
chriscarrollsmith merged 3 commits into
mainfrom
fix/218-postgres-rate-limiter
Jul 2, 2026
Merged

fix: add Postgres-backed rate limiter for multi-worker deployments#222
chriscarrollsmith merged 3 commits into
mainfrom
fix/218-postgres-rate-limiter

Conversation

@chriscarrollsmith

Copy link
Copy Markdown
Contributor

Summary

  • Add RateLimitAttempt table and PostgresRateLimitWindow for shared rate-limit state
  • Select backend via RATE_LIMIT_BACKEND (memory default, postgres for multi-worker)
  • Document the setting in .env.example and add Postgres integration test

Closes #218

Test plan

  • uv run pytest tests/utils/test_rate_limit.py tests/routers/core/test_account.py -k rate_limit
  • uv run ty check .

chriscarrollsmith and others added 3 commits July 2, 2026 16:33
Store rate-limit attempts in a shared table when RATE_LIMIT_BACKEND=postgres
so configured limits apply cluster-wide instead of per process.
Drop the legacy implementation left after merging trusted-proxy support
so ruff F811 passes in CI.
@chriscarrollsmith chriscarrollsmith merged commit d46bddf into main Jul 2, 2026
2 checks passed
@chriscarrollsmith chriscarrollsmith deleted the fix/218-postgres-rate-limiter branch July 2, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: in-memory rate limiter is per-process

1 participant