I have a web service exposed using the Flask framework.
This service uses as external API, which has a limitation on the number of times it should be called per second.
In a normal scenario, multiple calls to my API leads to multiple threads getting generated and the external API getting called without any control on the number of requests per second.
Is there a way in which I can queue requests to my web service and then call the external API in a throttled way.
Any other ideas are also welcomed.
Edit:
I already know the rate to the external API ( 1 request per second)
I am ok if the client requesting my API has to wait a little long (few seconds / minutes depending on the load I have) before they get the results.
I don't want my API clients to get failed results. i.e. I don't want them to call again and again. If the external API is already being accessed by me at the max rate possible, the requests to my API should get queued and processed when the rate comes down.
I read about Celery and Redis. Will I be able to queue the web service calls in to these queues and process them later ?