G
G
grabbee2017-05-14 10:22:05
symfony
grabbee, 2017-05-14 10:22:05

Symfony API request limit, how best to implement?

I'm trying to make an API service, it's logical to somehow provide a limit for requests to its methods. The guides don't talk about it. How to implement it correctly if you do it yourself? Perhaps you are using something ready for this? We need the ability to limit the number of requests per minute / hour for authorized users by their ID for different methods in different ways

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-04-21
@dastanaron_dev

In general, there is such a thing in the guides: https://symfony.com/doc/current/rate_limiter.html
On this topic, it is better to google something like this: Throttling in the {FRAMEWORK_NAME}, then usually there are some ready-made solutions.
But if you need to control for different methods, then your own implementation is better. I think redis is good for such things, where you can very quickly write data like this rate-limit:methodName:requestCount = 1 and increment this number with each request, and check the corresponding key in redis before the request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question