jmrozanec / jmrozanec/cron-utils-scheduler

Hash based spread to produce even load on the system

Open
#1 3 comments 0 reactions 0 assignees View on GitHub
contributions welcome feature
Dominant language
Java
Stars
14
Forks
5
PR merge metrics
No merged PRs in 30d

Description

I would be interested in support for the jenkins cron syntax, using a hash of some identifier they do a deterministic spread of cron jobs. eg H/15 would for example give you execution at 4.234 / 19.234 / 34.234 / 49.234 th minute. Even on a restart/reschedule with the same Id you will end up with these execution times.

> To allow periodically scheduled tasks to produce even load on the system, the symbol H (for “hash”) should be used wherever possible. For example, using 0 0 * * * for a dozen daily jobs will cause a large spike at midnight. In contrast, using H H * * * would still execute each job once a day, but not all at the same time, better using limited resources.

https://github.com/jenkinsci/jenkins/blob/master/core/src/main/resources/hudson/triggers/TimerTrigger/help-spec.html#L38

Implementation is done like this:

1. Use the provided id and make a hash (md5)
2. use that hash to initialize Random
3. use this random to replace the H values

https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/scheduler/Hash.java

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.