AWS Lambda's Automatic Retry Behavior
AWS Lambda's behavior for automatic retries on failure depends on how the Lambda function is triggered.
Asynchronous Invocation: When Lambda functions are triggered by asynchronous events, like S3 events or SNS messages, Lambda automatically retries failed executions. The first retry happens almost immediately, and the second retry occurs a few minutes later.
Synchronous Invocation: For synchronous invocations, such as those made through API Gateway or the Lambda API, Lambda does not automatically retry. The client must handle errors and retry as needed.
Stream-based Triggers: With stream-based triggers, such as DynamoDB or Kinesis streams, Lambda continues to read from the stream and reprocess failed records until they are processed successfully.
How to Change Retry Settings
-
Changing Asynchronous Retry Settings
- Log in to the Lambda console and select your function.
- Open the 'Configuration' tab and click on the 'Asynchronous invocation' section.
- Change settings for retry attempts or Dead Letter Queues (DLQs).
-
Stream-based Retry Settings
- For stream-based triggers (DynamoDB or Kinesis), you can configure batch size, batch window, and retry policies.
- These settings can be changed in the trigger's configuration page.
Important Considerations
- It's crucial to understand the automatic retry behavior correctly and ensure the idempotency of your processing.
- Setting up Dead Letter Queues (DLQs) can help retain messages that fail to be processed for later analysis.
Top comments (0)