Liveautomationshipped v1.0.0
Retry & Backoff Calculator
Design and visualize retry strategies for API calls. Configure base delay, max retries, backoff multiplier, max delay cap, and jitter type (full, equal, decorrelated). See a timeline visualization of retry attempts, total elapsed time, and probability distribution of delays with jitter.
retrybackoffapiresilienceautomation
strategy:
Delays
total: 17.5s#1
40ms
#2
114ms
#3
360ms
#4
211ms
#5
835ms
#6
1.6s
#7
6.2s
#8
8.1s
Code snippets
JavaScript
const delay = (ms) => new Promise(r => setTimeout(r, ms));
async function retryWithBackoff(fn, opts = {}) {
const { base = 100, factor = 2, max = 60000, attempts = 8 } = opts;
let last;
for (let i = 0; i < attempts; i++) {
try { return await fn(); }
catch (e) {
last = e;
const exp = Math.min(base * factor ** i, max);
const jitter = Math.random() * exp;
await delay(jitter);
}
}
throw last;
}Python
import time, random
def retry(fn, base=0.1, factor=2, max_delay=60, attempts=8):
for i in range(attempts):
try: return fn()
except Exception as e:
if i == attempts - 1: raise
d = min(base * factor ** i, max_delay)
time.sleep(random.uniform(0, d))🔒 Use exp+jitter to avoid thundering herd. AWS recommends "full jitter".