You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rather than holding a fixed set of delays, it would be useful to include a calculation function, which could build in jitter. Something along the lines of:
@initial_retry_interval15_000@max_retry_interval900_000defretry_interval(failed_count)do# Apply exponential backoff with `initial_retry_interval` on the# number of attempts so far as inputs. Do not allow the number to exceed# `max_retry_interval`sleep_millis=min(@initial_retry_interval*:math.pow(2,failed_count-1),@max_retry_interval)# Apply some jitter by randomizing the value in the range of `sleep_millis / 2` to `sleep_millis`# For instance, if sleep seconds are 15, we will actually respond at some time between 7.5s and 15ssleep_millis=sleep_millis*(0.5*(1+:rand.uniform()))# But never sleep less than the base sleep secondsmax(@initial_retry_interval,round(sleep_millis))end
Thoughts?
The text was updated successfully, but these errors were encountered:
defretry(channel,partition,job)do{queue,expiration}=setup_retry_queue(channel,partition,job)expiration=ifApplication.get_env(:roger,:jitter?)do# Apply some jitter by randomizing the value in the range of `expiration / 2` to `expiration`# For instance, if expiration is 15, we will actually respond at some time between 7.5s and 15sexpiration*(0.5*(1+:rand.uniform()))elseexpirationendpayload=Job.encode(%Job{job|retry_count: job.retry_count+1})opts_extra=caseexpirationdo:buried->[]_->[expiration: Integer.to_string(round(expiration*1000))]endAMQP.Basic.publish(channel,"",queue,payload,Job.publish_opts(job,partition)++opts_extra){:ok,expiration}end
Fixed retry periods can lead to a thundering herd problem.
Rather than holding a fixed set of delays, it would be useful to include a calculation function, which could build in jitter. Something along the lines of:
Thoughts?
The text was updated successfully, but these errors were encountered: