Add per URI rate limiting (DDoS protection) #109
Merged
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.
User description
This is tracked in #107. With this change you can configure per URI limits to prevent DDoS attacks.
PR Type
Enhancement
Description
Enhanced rate limiting system to prevent DDoS attacks by implementing URI-based rate limiting:
max_uri_requests_per_window
(default: 2000)max_uri_requests_per_bucket
(default: 100)This change addresses the DDoS vulnerability where multiple IPs could collectively overwhelm a specific URI endpoint while staying under individual IP limits.
Changes walkthrough 📝
ratelimit.go
Implement URI-based rate limiting for DDoS protection
pkg/backend/ratelimit/ratelimit.go
metrics.go
Add separate metrics for IP and URI rate limiting
pkg/backend/ratelimit/metrics.go
config.go
Add URI rate limit configuration parameters
pkg/backend/config.go
ratelimit_test.go
Add test coverage for URI rate limiting functionality
pkg/backend/ratelimit/ratelimit_test.go