Why does my Lambda function wait for the timeout before processing the next SQS batch?

0
34
Asked By CuriousCoder42 On

I'm running a Lambda function that uses SQS triggers set to a visibility timeout of 1 minute, with an execution timeout also at 1 minute. The issue I'm facing is that even if my function processes its current batch in less than 10 seconds, it doesn't pick up another batch until after the visibility timeout of 1 minute has elapsed. I'm looking for advice on whether there's something I might not be returning in my Lambda function that would allow it to trigger another execution right away, or if this is more of a configuration issue with the SQS event trigger. Just to clarify, my batch window is set to 0 seconds, and I have reserved concurrency set to 1 due to limitations with a third-party API.

5 Answers

Answered By LambdaLover99 On

You might want to check if you're properly acknowledging the messages with something like `message.delete()`. Just a thought.

Answered By SQS_Specialist On

What type of SQS queue are you using, Standard or FIFO? Just checking if that might have an impact.

Answered By CodeCracker123 On

Actually, you don't need to worry about deleting messages yourself. Lambda manages that automatically. If your function completes without any exceptions, the message gets deleted. It sounds like the reserved concurrency setting is causing the delay. With it set to 1, Lambda won't trigger a new execution until the timeout expires, which is why you're waiting for a minute.

Answered By DevDynamo On

Your visibility timeout should ideally be at least six times longer than your function timeout. Having a reserved concurrency of 1 might lead to throttling issues. You could try increasing the visibility timeout to 6 minutes and consider using a FIFO queue with a single message group ID to maintain a single execution.

Answered By TechGuru88 On

Is your `MaximumBatchingWindowInSeconds` set to zero? It sounds like that could cause issues. Can you share your event source mapping configuration? It might help figure this out.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.