I have defined an SQS
trigger to my Lambda. Inside the Lambda, I am calling a 3rd party api
which is based on tokens(250 tokens per minute). Initially I had defined a batch size of 250
, batch window of 65s
, but what happened was that the lambda worked concurrently
to process the requests and the tokens got exhausted very fast.
Then after changing various values of batch size, window and concurrency, finally the process started working smooth with batch size 10, batch window 10 and reserved concurrency 7 but that time there were only 3,00,000 product ids in the queue. Yesterday when I pushed 4 million product ids to the queue, again the tokens started getting exhausted very fast. When I checked the logs, I found that Lambda is picking different number of messages at different intervals like sometimes for a minute it takes 200 messages and sometimes 400. This number differs every time.
What I want is that Lambda should pick only 250 messages from the queue in 1 minute no matter how many messages are there in the queue. How to do this?