DEV Community

STYT-DEV
STYT-DEV

Posted on

AWS Lambda Automatic Retry on Failure and How to Configure It

AWS Lambda's Automatic Retry Behavior

AWS Lambda's behavior for automatic retries on failure depends on how the Lambda function is triggered.

  1. 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.

  2. 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.

  3. 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

  1. 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).
  2. 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.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay