Reputation: 25
a little question about SQS message concurrency.
scenario:
i created lambda with 3 minute timeout.
this lambda triggered by SQS service (with default configuration).
when SQS trigger my lambda he waiting X second (under 3 minute).
after waiting, he run the same lambda again.
now, i have two lambdas run in the same time.
for this case, in the end - lambda_1 is failed and lambda_2 Succeeded.
the question:
the SQS message is remove from the queue?
lambda which Succeeded deletes the message from queue.
lambda which failed do retry for this message.
and how can i control concurrency issue?
thank you.
Upvotes: 1
Views: 2545
Reputation: 238747
For SQS message to be removed from the queue, lambda has to explicitly delete it from the queue upon successful processing. (<- this is incorrect, see the edit below).
If lambda fails while processing the message, the message will be returned to the queue when message visibility timeout finishes (default is 30 seconds). Thus, it will have a chance to be processed again by lambda.
In your SQS queue settings, you can setup Dead-Letter Queues to store messages that failed to be processed successfully for number of tries.
Edit:
As @michael-sqlbot correctly pointed out, the first part on my answer was incorrect. When your function successfully processes a batch, Lambda deletes its messages from the queue.
To control lambda concurrency use Reserved Concurrency setting.
Upvotes: 2