Skip to content

chore: drop github per user rate limit tracking #12286

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

Merged
merged 4 commits into from
Feb 23, 2024

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Feb 23, 2024

Rate limits for authenticated requests are per user. This would be an excessive number of prometheus labels, so we only track the unauthorized limit.

The rate limit labels without a user label make no sense.

Closes: #10853

Unauthenticated Rate Limit

We used to hit the unauthenticated rate limit as our ValidateToken always required an external auth request. With #11830, we no longer waste an external auth request if we know the token is invalid.

Additionally, if we have an invalid token (say it was revoked), #11598 prevents us from constantly making an external auth request with the same invalid token in the "listen" loop. So when requiring a re authentication, we only trigger 1 request.

There is still improvement to be made, as an invalid token can trigger multiple requests if the user hits the same endpoint multiple times. The caching of "invalid" is only in the scope of 1 request atm. We could either persist the cached "invalid" to the db, or delete the link when we get a 401 back?

Rate limits for authenticated requests are per user.
This would be an excessive number of prometheus labels,
so we only track the unauthorized limit.
@Emyrk Emyrk requested a review from johnstcn February 23, 2024 15:28
Copy link
Member

@johnstcn johnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense, and I'm down for dropping unnecessary prom metrics 👍

Just need to make CI happy.

@Emyrk
Copy link
Member Author

Emyrk commented Feb 23, 2024

Just need to make CI happy.

Forgot to fix the tests for the rate limits. On it 👍

@Emyrk Emyrk merged commit 13359aa into main Feb 23, 2024
@Emyrk Emyrk deleted the stevenmasley/github_rate_limit branch February 23, 2024 17:17
@github-actions github-actions bot locked and limited conversation to collaborators Feb 23, 2024
@@ -12,8 +12,8 @@ coderd_oauth2_external_requests_rate_limit_reset_in_seconds{name="primary-github
coderd_oauth2_external_requests_rate_limit_reset_in_seconds{name="secondary-github",resource="core"} 121.82186601
# HELP coderd_oauth2_external_requests_rate_limit_total The total number of allowed requests per interval.
# TYPE coderd_oauth2_external_requests_rate_limit_total gauge
coderd_oauth2_external_requests_rate_limit_total{name="primary-github",resource="core"} 5000
coderd_oauth2_external_requests_rate_limit_total{name="secondary-github",resource="core"} 5000
coderd_oauth2_external_requests_rate_limit_total{name="primary-github",resource="core-unauthorized"} 5000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 60 instead of 5000?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be, but it's only used to generate docs. The values are ignored, but the labels are included.

https://coder.com/docs/v2/latest/admin/prometheus#prometheus-configuration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it is fine

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GitHub Rate Limit
3 participants