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

wip: spike on adding rate limits to freeway #109

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Conversation

travis
Copy link
Member

@travis travis commented Jun 13, 2024

Add a new middleware that checks a rate limiting service and returns a 429 if the CID is over a rate limit.

This sketches out an API for the rate limiting and accounting services suggested in storacha/RFC#28

This is not ready to merge, but should probably be the starting point for this work once we all agree that this is the right shape.

Add a new middleware that checks a rate limiting service and returns a 429 if the CID is over a rate limit.

This sketches out an API for the rate limiting and accounting services suggested in storacha/RFC#28

This is not ready to merge, but should probably be the starting point for this work once we all agree that this is the right shape.
@travis travis marked this pull request as draft June 13, 2024 22:56
introduce a KV namespace for caching token metadata - for now the "invalid" boolean is the most important thing, as that's how we decide whether a token is valid.

I thought we'd be able to serve tokened requests when in doubt, but I'm a bit worried about people generating random tokens if we go that route - sending a different random token with each request would theoretically allow them to make infinite unbilled requests.

instead I went with a pattern that will likely require us to warm the cache before a token-based request achieves hot-storage level performance - we cache auth token metadata in KV and wait for the accounting service to return it if we don't find it in the cache. Using a "Stale While Revalidate" pattern to update the cache will allow us to maintain performance and the ability to disable tokens.
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.

1 participant