1

I can trigger and EventBridge (rule/schedule feature formerly in CloudWatch) scheduled function with a rate (say, once-every 5 minutes) or via a cron setup to do the same.

And the rate-setting will routinely trigger at: 7:05:13, 7:10:13, 7:15:13, etc.

If I delete the EventBridge rule and rebuild it, it will trigger at: 7:05:42, 7:10:42, 7:15:42, etc...

My guess is that it starts at the second that the rule first goes into effect and just dutifully tiggers at that rate.

I need to trigger at exactly the same second - preferably the zeroth second or some other very-close-to-zero value because I'm doing syncronized data collection with another process that DOES collect on the zeroth second - is there a way to define the start second of a EventBridge scheduled task rule (particularly helpful would be if there was a way to do it with the serverless framework)?

I've tried with a cron setup and had the same basic results (different seconds, of course, but still not the zeroth second - and the second it fired changed on every deployment of the rule)

Shy of ensuring my enterprise-scale serverless framework deployment goes out at the zeroth-second every time (something that's not reasonable for a large-scale multi-member project) how can I set the second-level timing of a cron or rate-based rule task in eventBridge (formerly cloudwatch)?

Previous questions (How can I schedule cloudwatch rule at second level?) have implied that the default is that things trigger at the zeroth second, but that doesn't seem to be the case.

lowcrawler
  • 6,777
  • 9
  • 37
  • 79
  • Please don't include Google redirect links. Just include the target page's link. – jarmod Dec 01 '21 at 16:56
  • Would it be viable to trigger a Lambda one minute early, and then wait until the 00 second to do whatever it is you need to. Will waste 30 seconds on average, but probably not terrible. – jarmod Dec 01 '21 at 17:00
  • It might be a better idea to have this other service trigger the lambda instead. – gshpychka Dec 01 '21 at 17:07
  • This lambda actually gets triggered once a minute and lasts around 5-10 seconds (it's pulling async data from a different api).... Doing it on the 'prior minute' and waiting would effectively mean I'd have a lambda running 24/7.... that's ... less than ideal. – lowcrawler Dec 01 '21 at 17:57

1 Answers1

1

EventBridge does not provide second accuracy. It does not guarantee the execution at exact minute/seconds, even though you observe it.

If you need execution at second accuracy, then EventBridge is not the right tool for you.

As noted here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html

CloudWatch Events does not provide second-level precision in schedule expressions. The finest resolution using a cron expression is a minute. Due to the distributed nature of the CloudWatch Events and the target services, the delay between the time the scheduled rule is triggered and the time the target service honors the execution of the target resource might be several seconds. Your scheduled rule is triggered within that minute, but not on the precise 0th second.

Vincent J
  • 4,968
  • 4
  • 40
  • 50
  • "then EventBridge is not the right tool for you." -- suggestions for alternative solutions? – lowcrawler Feb 04 '22 at 19:56
  • I would probably run a separate permanent docker container with a scheduler like https://schedule.readthedocs.io/en/stable/ which would invoke lamba. lambda has to be provisionned for concurrency to reduce warmup latency that may be several seconds itself. – Vincent J Feb 06 '22 at 11:53