Reputation: 5102
I have a long running lambda (15 minutes).
I call it with this:
aws lambda invoke --region us-west-2 --profile prof --function-name func --invocation-type Event response.json
I expect the lambda to be invoked once. However, its usually invoked at least 3 times.
I can try to avert this by setting reservedConcurrency=1
, but I at times get:
TooManyRequestsException: Rate Exceeded.
Why was my lambda called 3 times? Is there something in the documentation that could help demystify this behaivor?
MY THEORY:
My theory is that because it's a long running lambda, the lambda will be called a few times because the timeout on some client is not long enough.
Is it because I have retry attempts at 2 in the settings?
Upvotes: 2
Views: 618
Reputation: 238169
Is there something in the documentation that could help demystify this behaivor?
I seems there are some errors in your lambda function causing it to fail. If this happens during asynchronous invocation, the lambda is going to retry your function twice:
Lambda retries function errors twice. If the function doesn't have enough capacity to handle all incoming requests, events might wait in the queue for hours or days to be sent to the function. You can configure a dead-letter queue on the function to capture events that weren't successfully processed.
This would explain why your function is invoked 3 times: 1 normal time + 2 retries.
Usually CloudWatch Logs
would enable you to identify the issue. Dead Letter Queue is also helpful to capture the events which lead to failures.
Upvotes: 3