AWS Lambda - 如何在出现故障时停止重试 [英] AWS Lambda - How to stop retries when there is a failure
本文介绍了AWS Lambda - 如何在出现故障时停止重试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道当 Lambda 函数失败时(例如超时时),它会尝试再次运行该函数 3 次.有什么办法可以避免这种行为吗?我一直在阅读文档,但没有找到任何相关信息.
I know that when a Lambda function fails (for example when there is a time out), it tries to run the function 3 more times again. Is there any way to avoid this behavior? I' have been reading the documentation, but didn't find anyting about this.
谢谢!
推荐答案
已编辑:现在可以更改 lambda 设置以禁用重试(请参阅 公告一>)
EDITED: It's now possible to change the lambda settings to disable retries (see announcement)
原答案:
没有办法禁用 Lambda 函数的重试行为.我建议两种选择来解决这个问题:
There isn't a way to disable retry behavior of Lambda functions. I suggest two options to deal with that:
- 使您的 Lambda 能够正确处理重试情况.您可以使用在重试 Lambda 时相同的 context.AwsRequestId(或相应字段).
- 将您的 Lambda 放入状态机(使用 AWS Step Functions).您只能然后禁用重试.这篇博文我写的给出了更一般的解释.
- Make your Lambda able to handle retry cases correctly. You can use context.AwsRequestId (or corresponding field) that will be the same when a Lambda is retried.
- Put your Lambda inside a state machine (using AWS Step Functions). You can only then disable retries. This blog post I've written gives a more general explanation.
这篇关于AWS Lambda - 如何在出现故障时停止重试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文