Balancing Watcher execution times

Hi,

Most of our Watchers execute on a 15 minute interval. We have about 50 watches, so ideally these should execute at "balanced" times; 50 Watchers should not execute simultaneously at 00:00, 00:15, ... for example.

Does interval: 15m this mean that:

  • Each Watcher runs at 00:00, 00:15, 00:30, ..., 23:45. In cron-speak, */15 * * * *
  • Or, that they run at multiples of fifteen minutes after the watcher was created (e.g 00:17, 00:33, ...)?

If they run at */15 * * * *, is there any built-in way to spread the Watcher execution time out. equivalent to the Jenkins syntax H/15 * * * *?

Regards,
Ryan

Hey Ryan,

the interval schedule does not give any guarantees that watch executions will be distributed, especially after a master node switch or a cluster restart (where the interval will be used, to potentially run all watches next to each other).

You could use the hourly schedule likes this and distribute the watches

"hourly" : { "minute" : [ 0, 15, 30, 45 ] }

or just use a cron expression as you mentioned. You can use the bin/watcher/croneval tool to make sure your cron expression can be parsed correctly by watcher.

--Alex

Hi Alex,

I think your suggestion of using the hourly schedule to distribute watchers is a sensible workaround; I can force them to be distributed evenly when I'm generating each watcher (thankfully I do this programmatically). e.g for three watchers

# a.
"hourly" : { "minute" : [ 0, 15, 30, 45 ] }
# b.
"hourly" : { "minute" : [ 5, 20, 35, 50 ] }
# c.
"hourly" : { "minute" : [ 10, 25, 40, 55 ] }

Thanks (as always),
Ryan

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.