-
-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
Implement a Token Bucket algorithm using TDD which limits requests based on a user's IP address and allows developers to provide the desired CAPACITY and REFILL_RATE (in milliseconds).
The algorithm should consider each request to consume exactly 1 token. It should not consider GraphQL query complexity when limiting requests.
The TokenBucket instance of a RateLimiter limits requests based on a unique user ID.
Whenever a user makes a request the following steps are performed:
- Refill the bucket based on time elapsed since the previous request
- Update the timestamp of the last request.
- Allow the request and remove the requested amount of tokens from the bucket if the user has enough.
- Otherwise, disallow the request and do not update the token total.
For more information on implementing a Token Bucket Algorithm see the following resources:
Metadata
Metadata
Assignees
Labels
No labels