首页 > 解决方案 > Aws Lambda function triggers on a delay time for 2 out of 3 cron jobs

问题描述

I have a Lambda function that has 3 event triggers here are the Cron job for each:

Cron 1: cron(50/1 22 * * ? *)

Cron 2: cron(50/1 12 * * ? *)

Cron 3: cron(*/15 * * * ? *)

Now Cron 2 Timestamp logs reads as follows, which is ok. Notice that it starts 2-3 seconds into the intended trigger:

10
2021-07-10T05:59:03.867-07:00
11
2021-07-10T05:59:03.867-07:00
12
2021-07-10T05:59:02.314-07:00
START
13
2021-07-10T05:58:02.988-07:00
END 
14
2021-07-10T05:58:02.988-07:00
15
2021-07-10T05:58:02.547-07:00
START 

BUT Cron 1 & 3 starts over 30+ seconds into the intended trigger. I compared everything possible and there are no settings that are different (to my knowledge). Any idea why 2 of the 3 events have a delay but one doesn't? I understand a small 1-5 second delay by reading here https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html but somethings seems to be off.

2021-07-10T06:30:37.253-07:00
2
2021-07-10T06:30:37.253-07:00
3
2021-07-10T06:30:33.929-07:00
4
2021-07-10T06:15:36.931-07:00
5
2021-07-10T06:15:36.931-07:00
6
2021-07-10T06:15:33.881-07:00
7
2021-07-10T06:00:34.037-07:00
8
2021-07-10T06:00:34.037-07:00
9
2021-07-10T06:00:33.596-07:00

标签: amazon-web-servicesamazon-s3aws-lambdacronaws-event-bridge

解决方案


Event Bridge的精度为一分钟:

所有计划的事件都使用 UTC+0 时区,计划的最小精度为一分钟。您计划的规则在那一分钟内运行,但不是在精确的第 0 秒内运行。

因此,您的延迟非常好,并且在 1 分钟的间隔内。


推荐阅读