-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: token bucket rate limiting #91
Conversation
243ac32
to
7cf683d
Compare
// Rate limiting | ||
|
||
export const lowRateLimiterConfiguration: TokenBucketConfiguration = { | ||
capacity: 500, |
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.
A maximum of 500 requests per minute is going to be what we ask our prototyping partners to follow for V1. When the Rate limiter is released we will actually be able to see whether it is a good starting point for our users.
}; | ||
|
||
export const highRateLimiterConfiguration: TokenBucketConfiguration = { | ||
capacity: 1000, |
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.
The high capacity token bucket is not going to be used for now as the web app feature to enable it is not a priority at the moment.
7cf683d
to
ea4861f
Compare
132262b
to
f400655
Compare
f400655
to
3340dfa
Compare
Summary | Résumé
Should not be merged until V1 is released to production (unless we decide to include it in V1).
Context: cds-snc/platform-forms-client#3947
cache
(in lib/utils) toredisClientAdapter
(in lib/integration/redis). The rate limiter code uses Redis to get a value that will be set by the web application. Since there is no cache concept involved here I decided to rename the two cache related functions. This way we can use it everywhere we need to access Redis and it also simplifies the mocks in our unit tests.Test instructions
config.ts
file to lower the token bucket capacity for bothlowRateLimiterConfiguration
andhighRateLimiterConfiguration
X-RateLimit
properties) and response HTTP code (will be 429 when you have reached the limit)rate-limit:${formId}
=> "high"