I have a question about how to slow down my api requests. For a particular third party API I am hitting allows me to make 3 requests every 2 seconds. If I go over that number I am returned status code 429
along with a wait time in milliseconds.
This api is called often and is a direct result of my own server having incoming requests which are not rate limited.
Since I do not have any need for synchronous handling of the third party api requests I decided to offload the work to my elastic beanstalk worker box on AWS which by default reads from Amazon SQS.
As a result, my worker will throw the SQS message back into the queue if a status code 429 is returned from the third party api. This inevitably makes the api call work when the waitime is reached. This however seems like a bad solution
Is there any way to tell the daemon on the worker box to leave the message in the queue for the allotted wait time? Or can I perhaps set the rate at which the daemon will read from the queue? I'm looking for a proper way (implementation specific) to rate limit using the worker and the queue on AWS. Thank you so much for the help!
EDIT: I would have assumed that there are configurations that could be modified on AWS to do what I am asking but either way I'm looking for specific solutions for the setup I described. I'm not quite sure how to modify or control the daemon on the elastic beanstalk worker box.