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
已提问 1 年前806 查看次数
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
已回答 1 年前
  • @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
专家
已回答 1 年前
profile picture
专家
已审核 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则