简体   繁体   English

AWS Cloudwatch/Lambda - 计划事件触发太频繁

[英]AWS Cloudwatch/Lambda - scheduled event is triggered too often

i created an AWS Lambda function , and created a scheduled event rule in Cloudwatch to trigger it every 5 minutes : Schedule Cron expression : 0/5 * * * ? *我创建了一个AWS Lambda 函数,并在Cloudwatch 中创建了一个计划事件规则以每 5 分钟触发一次: Schedule Cron expression : 0/5 * * * ? * Schedule Cron expression : 0/5 * * * ? *

The problem is that when looking at the logs, the Lambda seems to be executed every 1~2 minute.问题是在查看日志时,Lambda 似乎每 1~2 分钟执行一次。

I checked the CRON expression, it seem correct because AWS shows previews of the next triggers.我检查了 CRON 表达式,它似乎是正确的,因为 AWS 显示了下一个触发器的预览。 I also tried with a rate expression, but i still have the same issue.我也尝试过使用速率表达式,但我仍然遇到同样的问题。

I tooks a look at cloudwatch metrics : - The scheduled event seems fine, it triggered once every 10minutes - The lambda invocation metric show that it is invoked more often我查看了 cloudwatch 指标: - 计划事件似乎很好,每 10 分钟触发一次 - lambda 调用指标显示它被更频繁地调用

Any help ?有什么帮助吗?

Thanks @JohnRotenstein for the lead,感谢@JohnRotenstein 的带领,

the issue came from the returned result from the NodeJS promise.问题来自 NodeJS 承诺的返回结果。 If the JS handler doesn't give back any result inside the returned promise, lambda considers the execution as a failure.如果 JS处理程序没有在返回的承诺中返回任何结果,则 lambda 将执行视为失败。

In my case i simply had to return a value (even null ) so that the execution completes successfully.在我的情况下,我只需要返回一个值(甚至null ),以便执行成功完成。 Otherwise it looks like lambda will to re-execute the code 1~2 minutes later否则看起来 lambda 会在 1~2 分钟后重新执行代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM