Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Commit

Permalink
fix: add 10% jitter to backoff algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
watson committed Nov 11, 2018
1 parent 7246cf0 commit d22aea1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ function Client (opts) {
this._errors++

const retryIndex = this._errors === 0 ? 0 : this._errors - 1
const backoff = (Math.min(retryIndex, 6) ** 2) * 1000
const jitter = Math.random() * 0.2 + 0.9 // ±10% jitter
const backoff = (Math.min(retryIndex, 6) ** 2) * 1000 * jitter

if (backoff > 0) {
this._chopper.resetTimer(-1) // disable timer to prepare for back-off mode
Expand Down

0 comments on commit d22aea1

Please sign in to comment.