-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add conservative traefik rate-limit to strfry #94
Open
dcadenas
wants to merge
1
commit into
main
Choose a base branch
from
traefik-rate-limit-to-relay
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these per-second?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, most would be req requests and I'm assuming many will be long lived for at least a second but it should probably be higher than 1 and tweak according to what we see
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://doc.traefik.io/traefik/middlewares/http/ratelimit/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to set these a lot higher. I guess I'm not sure how exactly it does rate limits for websockets, but I assume every
socket.write
call counts as one request. For example when Nos downloads the home feed it will burst out a bunch of requests for the notes, then their profile pics, metadata. Same in the thread view. Something more like burst 100 and average 5 seem "conservative" to me. I'm not sure how much those would insulate from a bad actor or DDoS but I don't think that's necessarily the intention here, I think we are just trying to prevent some runaway script from infinite looping on us.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I just read the docs about the "token bucket" style of rate limiting traefik is using. With the way it works I think the numbers I listed are pretty safe and won't catch normal apps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk a burst of 100 would definitely catch a Nos user scrolling rapidly through a feed because it's kicking off at least one request for each note. Maybe 1000 is better? And if someone is DDosing it would still time them out them pretty quickly? It's hard to draw these lines without real world data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about these values more as a binary search exploration because I'm not really sure how they are interpreted, I was assuming it was per connection request, not per internal websocket frame. In any case your proposed values seems safe