Skip to content

Instantly share code, notes, and snippets.

@monkeyarmada
Created March 30, 2022 11:20
Show Gist options
  • Save monkeyarmada/2f9f34c576c3c8c4c61879a0159df108 to your computer and use it in GitHub Desktop.
Save monkeyarmada/2f9f34c576c3c8c4c61879a0159df108 to your computer and use it in GitHub Desktop.
Exponential backoff test
let backoff = 500;
let backofflimit = 10 * 60 * 1000;
let accumulated = 0;
for (let step = 1; step < 15; step++){
let wait = Math.pow(1.26, step) * backoff;
if (wait > backofflimit) wait = backofflimit - (Math.random() * 1000);
accumulated += wait;
console.log(Math.floor(wait));
}
console.log(Math.floor(accumulated/1000));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment