OiO.lk Blog python Short Polling in Infinite Loop Python on AWS
python

Short Polling in Infinite Loop Python on AWS


I have a Python script that continuously polls an API in an infinite loop. In each cycle, it makes 30 separate API calls, one after the other. After completing these calls, the script waits for about 10 seconds before starting the process again.

I’m looking to make this script more efficient. Should I use asyncio to send all 30 requests at the same time instead of one by one?

Also, since I want the script to run continuously, I’m considering deploying it on AWS Lambda. I could set it up as a cron job to run every minute instead of using the infinite loop. Alternatively, I could use Amazon ECS with an infinite loop, and use systemd or a similar tool to restart the script if it stops.

Are there better ways to handle short polling in this situation?

I tried infinite loop approach with short polling haven’t deployed it yet but I somehow feel it isn’t efficient as I might need to increase the request limit to let’s say 100 or even more than that



You need to sign in to view this answers

Exit mobile version