Lambda Retry on a specific Error Code

0

There's a Lambda function which calls other external service. If the service returns us 429 error code, Then the Lambda needs to retry the call until we get success, for a max of three times, with 10,20,30 minutes Gap.

The issue is Lambda can run only upto 15min's Max. So using timeout is not Possible.

How can this usecase be tackled? Thanks in Advance

kishore
질문됨 일 년 전807회 조회
2개 답변
2

Hello! Step Functions would be the ideal implementation. However maybe it can be an overkill if your implementation is very simple or if you want a quick solution.

For example, if you are using an SQS Queue to trigger the Lambda, a quick implementation could be to delete the message from the queue and re-publish it using what is called a "MessageTimer" with a DelaySeconds (more info here) property set to 10, 20, 30 minutes respectively (NOTE: minutes have to be specified in seconds within this property). Then, the queue will "hide" this message from publication until the specified delay has passed accomplishing the "retry" mechanism you are expecting.

Hope this helps!

PS: From the Amazon SQS documentation available here: "To set delay seconds on individual messages, rather than on an entire queue, use message timers to allow Amazon SQS to use the message timer's DelaySeconds value instead of the delay queue's DelaySeconds value."

profile pictureAWS
답변함 일 년 전
  • @kishore did my answer help?

0

Hi,

AWS Step Functions is a great service for use-cases like yours that involve orchestration. With Step Functions you can create a simple state machine that calls your AWS Lambda function. Step Functions has built-in retry and error handling, so you can configure the number of retries as well as the interval between them. For more information, please check: https://docs.aws.amazon.com/step-functions/latest/dg/concepts-error-handling.html

Please upvote/accept this answer if it was helpful.

profile pictureAWS
전문가
답변함 일 년 전
profile picture
전문가
검토됨 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠