Skip to content

How would I implement a random jitter for randomly scheduled jobs? #2227

Answered by lahma
hans-notifi asked this question in Q&A
Discussion options

You must be logged in to vote

For random jitter it's easiest to add a sleep (Task.Delay) in start of your job. This of course means that max_jitter + max_job_execution_time < trigger_interval must be true so that overlapping/queuing won't happen.

But your real problem might be that you should run database-backed job store that ensures that multiple instances of job are handled correctly - you can add DisallowConcurrentExecution attribute and cluster will obey that. Remember that concurrent execution checks are based on job keys.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hans-notifi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants