AWS Lambda函数针对具有相同时间戳的同一事件多次触发 [英] AWS lambda function triggering multiple times for a same event with same time stamp

查看:93
本文介绍了AWS Lambda函数针对具有相同时间戳的同一事件多次触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将AWS S3触发器配置为具有PUT操作的lambda函数.

I configured AWS S3 trigger to lambda function with PUT operation.

每2分钟上传大小为100kb的.txt文件.

Every 2 minutes uploading .txt file of size 100kb.

有时S3会在相同的事件和时间触发两次lambda.

Sometimes S3 will trigger lambda twice with same event and time.

触发1:

START RequestId:f32a3353-bd53-48fd-aa49-c09ee9c82a3e 2019-07-30T22:47:05.122Z

触发2:

START RequestId:f32a3353-bd53-48fd-aa49-c09ee9c82a3e 2019-07-30T22:47:05.98Z

如何避免这种情况?

推荐答案

让我引用该文档:

有时候,您的函数可能会多次收到相同的事件,即使没有错误发生.

Occasionally, your function may receive the same event multiple times, even if no error occurs.

另一个:

发生错误时,您的函数可能会多次调用.重试行为因错误类型,客户端,事件源和调用类型.例如,如果您异步调用一个函数并返回错误,Lambda最多执行两个函数时间.

When an error occurs, your function may be invoked multiple times. Retry behavior varies by error type, client, event source, and invocation type. For example, if you invoke a function asynchronously and it returns an error, Lambda executes the function up to two more times.

参考: https://docs.aws.amazon.com/lambda/latest/dg/API_Invoke.html

您的lambda必须是幂等的,才能处理此行为,请参见以下链接的更多详细信息:

Your lambda must be idempotent to handle this behavior, see more detail on links below:

https://aws.amazon.com/premiumsupport/知识中心/lambda-功能-幂等/

https://cloudonaut.io/您的lambda功能可能会执行两次与它的交易/

这篇关于AWS Lambda函数针对具有相同时间戳的同一事件多次触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆