Skip to content
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

Rate limiting strategy #500

Merged
merged 3 commits into from
May 13, 2021
Merged

Rate limiting strategy #500

merged 3 commits into from
May 13, 2021

Conversation

ebrown32
Copy link
Contributor

@ebrown32 ebrown32 commented Apr 22, 2021

This is a simple implementation that sends 429s if callers do too many invocations of any credential, client, or authorization in a given minute. It uses a simple in-memory per-node rate limiting scheme.

@ebrown32 ebrown32 force-pushed the rate_limiting branch 4 times, most recently from 78898bf to f690969 Compare April 22, 2021 20:58
Copy link
Member

@mike-marcacci mike-marcacci left a comment

Choose a reason for hiding this comment

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

This looks great (and so sorry for the slow review from me). This is a great API for this and solid collection of places to limit. I do think we could optimize the algorithm a bit – it's not clear to me that the existing one would actually be a problem in practice, but it does have high time complexity in the hot path. I proposed a possible alternative, but I may have missed some edge case there, so if you find issues with it, I'm OK starting with the original one.

packages/authx/src/util/ratelimiter.ts Outdated Show resolved Hide resolved
packages/authx/src/util/ratelimiter.ts Show resolved Hide resolved
Copy link
Member

@mike-marcacci mike-marcacci 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 my suggestion made prettier unhappy... it probably wants it on a new line. But in substance, this is perfect 👍🏼

@ebrown32 ebrown32 merged commit 7a87a77 into main May 13, 2021
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.

2 participants