Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash based spread to produce even load on the system #1

Open
francisdb opened this issue May 24, 2017 · 3 comments
Open

Hash based spread to produce even load on the system #1

francisdb opened this issue May 24, 2017 · 3 comments

Comments

@francisdb
Copy link

francisdb commented May 24, 2017

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

@jmrozanec
Copy link
Owner

jmrozanec commented May 24, 2017

@francisdb this is a great idea. Thank you for this suggestion!

@francisdb
Copy link
Author

The api should then let the user supply a unique id per job

@jmrozanec
Copy link
Owner

Yes - we agree on that! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants