Search code examples
pythontornado

how to add rate limiting on tornado python app


would it be possible to implement a rate limiting feature on my tornado app? like limit the number of HTTP request from a specific client if they are identified to send too many requests per second (which red flags them as bots).

I think I could it manually by storing the requests on a database and analyzing the requests per IP address but I was just checking if there is already an existing solution for this feature.

I tried checking the github page of tornado, I have the same questions as this post but no explicit answer was provided. checked tornado's wiki links as well but I think rate limiting is not handled yet.


Solution

  • The enterprise grade solution to your problem is ambassador. You can use ambassador's solutions like envoy proxy and edge stack and have it set up that can do the needful.

    additional to tore the data, you can use any popular cached db, or d that store as key:value pairs, for example redis.

    if you doing this for a very small project, can use some npm/pip packages.

    Read the docs: https://www.getambassador.io/products/edge-stack/api-gateway/