2

Are there any best practices for implementing rate limiting for an OAuth2 protected api?

I realise that REDIS is often used for this, but since I'm using a db to persist the tokens, I was thinking of using that for rate limiting as well. It would store the maximum number of queries for each token and decrement that each time the token is used and then reset the counter daily or hourly.

Any major problems with that approach?

1 Answer 1

3

The most common algorithm used for this is Token Bucket.

You can put the logic in your app and use redis or other db as a backend. Redis is particularly interesting for this because you can use things like TTL.

I have been working on another approach moving all the logic to a daemon. I don't have clients in other technologies than node.js yet but you can check the idea here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.