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

Add Rate Limiting #121

Merged
merged 1 commit into from
Jan 15, 2022
Merged

Add Rate Limiting #121

merged 1 commit into from
Jan 15, 2022

Conversation

imRohan
Copy link
Owner

@imRohan imRohan commented Jan 15, 2022

Some users have been long polling their Pantry every few ms, which will one day
cause problems for us.

To deal with issues like this, we should add a rate-limiting solution as to
prevent users from spamming the server.

This change addresses the need by:

  • Adding a Redis based rate-limiting solution
  • Allowing users to get the contents of a basket 30 times before rate limiting
    kicks in

Resolves #120

@imRohan imRohan added the Ready for Review Once you've squashed your commits, the PR is now ready for review! label Jan 15, 2022
@imRohan imRohan self-assigned this Jan 15, 2022
Some users have been long polling their Pantry every few ms, which will one day
cause problems for us.

To deal with issues like this, we should add a rate-limiting solution as to
prevent users from spamming the server.

This change addresses the need by:
- Adding a Redis based rate-limiting solution
- Allowing users to get the contents of a basket 30 times before rate limiting
  kicks in

Resolves #120
@imRohan imRohan merged commit 444fc66 into master Jan 15, 2022
@imRohan imRohan deleted the rl-rate-limiting branch January 15, 2022 22:05
@realpxl
Copy link

realpxl commented Jan 16, 2022

On getpantry.cloud I'm getting consistently 429 with 1 GET per minute. What's the timeframe for the 30 requests?

@imRohan
Copy link
Owner Author

imRohan commented Jan 16, 2022

Hi @realpxl

The rate-limiting logic has been slightly modified since this PR was merged. Here's a link to the lines in question (link).

Currently, every user can perform up to 20 GET requests to retrieve the contents of a basket before having to wait for a period of time between subsequent calls.

In theory, after receiving the 429 response, waiting for around 20s should be more than enough time to refresh your request count.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready for Review Once you've squashed your commits, the PR is now ready for review!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Rate Limiting
2 participants