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

Rest: Support shared/external rate limit tracking. #52

Open
paperdave opened this issue Jul 14, 2022 · 4 comments
Open

Rest: Support shared/external rate limit tracking. #52

paperdave opened this issue Jul 14, 2022 · 4 comments
Labels
enhancement New feature or request pkg:rest
Milestone

Comments

@paperdave
Copy link
Member

Something that might be interesting is if you could pass some object as a rateLimitTracker, which would be an interface that could accept, store, and return rate limit data observed by the fetcher. The idea being if you had rate limits stored on each shard of a bot (where shards are separate instances, maybe even on separate computers), you could optionally link them up using something like Redis. The idea being if all instances of a bot share the same rate limit store, it should reduce the chance of a 429 being returned during high usage.

Opt in behavior, we'd essentially refactor our rate limiting system to a MemoryRateLimitTracker which would be the default for the rest client.

@paperdave paperdave added enhancement New feature or request pkg:rest labels Jul 14, 2022
@paperdave
Copy link
Member Author

Oh, and then for purplet, we could offer this as a part of the config file, like config.rateLimitTracker or something.

@Hycord
Copy link
Contributor

Hycord commented Jul 14, 2022

ooh, I like this

@paperdave paperdave modified the milestone: post 2.0 Jul 15, 2022
@paperdave
Copy link
Member Author

paperdave commented Oct 17, 2022

we will use https://www.npmjs.com/package/keyv for this feature nevermind, this does not support non-node environments by default. we need to find an alternative.

it should be available by 2.0 release. in the purplet framework itself, this cache can be shared with the structures cache.

@paperdave paperdave added this to the 2.0 milestone Oct 17, 2022
@paperdave
Copy link
Member Author

code around here has to be modified to use the async key value store: https://github.com/CRBT-Team/Purplet/blob/main/packages/rest/src/Fetcher.ts#L37. shouldn't be too difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg:rest
Projects
None yet
Development

No branches or pull requests

2 participants