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: 11.6s#1
47ms
#2
191ms
#3
183ms
#4
702ms
#5
1.2s
#6
250ms
#7
2.8s
#8
6.2s
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".