Repository navigation
fix(rate-limit): add distributed Redis-backed rate limiting - #441
Merged
AnuranjanJain merged 8 commits intoJun 27, 2026
Merged
AnuranjanJain merged 8 commits into
AnuranjanJain merged 8 commits into
Conversation
|
@Namraa310806 is attempting to deploy a commit to the WizardKing's projects Team on Vercel. A member of the Team first needs to authorize it. |
coderashhar
suggested changes
Jun 22, 2026
coderashhar
left a comment
There was a problem hiding this comment.
Kindly resolve the failing checks
Contributor
Author
|
@coderashhar Done |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR upgrades the application's rate-limiting architecture from process-local enforcement to distributed Redis-backed enforcement, ensuring rate limits remain consistent across multiple workers and production deployments.
Previously, rate limiting relied on in-memory storage, allowing limits to be bypassed in multi-worker environments because each worker maintained its own independent state.
This PR activates and validates the existing distributed rate-limiting infrastructure, adds Redis support, improves configuration, and introduces comprehensive test coverage for concurrency and failure scenarios.
Root Cause
The project already contained Redis-based distributed rate-limiting infrastructure inside
backend/utils/limiter.py, including:RedisStorageLimiterStorageProxyHowever:
requirements.txtAs a result, rate limits could be bypassed by distributing requests across multiple application workers.
Changes Made
Distributed Rate Limiting
REDIS_URL.Authentication Security Improvements
Integrated existing authentication rate-limiting controls into:
/auth/login/auth/signup/auth/resend-verificationAdded enforcement for:
Configuration Improvements
Added Redis configuration examples and documentation to:
.env.examplebackend/.env.exampleDocumented:
and related rate-limiting settings.
Testing
Added comprehensive test coverage for distributed rate limiting.
New Test Suites
Distributed Rate Limiting
Concurrency Testing
Failure Scenarios
Results
Impact
Before
After
Security Benefits
This PR improves protection against:
Fixes: #419
Files Modified
Configuration
requirements.txt.env.examplebackend/.env.exampleAuthentication
backend/routers/auth_routes.pyTests
backend/tests/test_distributed_rate_limit.pybackend/tests/test_rate_limit_concurrency.pybackend/tests/test_rate_limit_failure_scenarios.pyDocumentation
docs/distributed-rate-limiting-refactor.mdBackward Compatibility
Checklist