Why is queue visibility timeout is recommended to be six times function timeout plus batch window?

Viewed 3563

From https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#events-sqs-queueconfig

Set your queue visibility timeout to 6 times your function timeout, plus the value of MaximumBatchingWindowInSeconds

Why can't the queue visibility timeout be equal to the function timeout? Let's say the function has a timeout of 30 seconds, so is the queue visibility. The function picks up the message and 30s passed, the message has not been deleted, now it's visible for other functions/consumers. Then why does it have to be 6 times? And what role does maxium batching window plays in queue visiblity timeout?

1 Answers

Then why does it have to be 6 times?

The explanation is given in the next sentence:

The extra time allows for Lambda to retry if your function execution is throttled while your function is processing a previous batch.

This is just a recommendation. You don't have to follow.

Related