Retry with backoff
Exponential backoff with jitter for resilient API calls and license checks.
Why backoff matters
Transient failures — rate limits, network blips, server restarts — are inevitable. Retrying immediately creates thundering-herd pressure. Exponential backoff with random jitter spreads retry attempts across time, giving upstream services room to recover while keeping your client responsive.
The algorithm
delay = min(cap, base * 2^attempt) delay = delay / 2 + rand(0, delay / 2)
Full jitter: pick uniformly from [0, delay]. Decorrelated jitter (shown above) keeps a floor of delay/2 to avoid clustering near zero.
Recommended defaults
- Base: 200ms
- Cap: 30s
- Max attempts: 5
- Jitter: full or decorrelated
- Retryable statuses: 429, 502, 503, 504
Circuit breaker integration
Pair backoff with a circuit breaker. After N consecutive failures, open the circuit and fail-fast for a cooldown period. This prevents cascading retry storms when a downstream service is hard-down. Meridian's license validator uses this pattern: 3 failures → 60s open → half-open probe.
Meridian tip: The loader applies this recipe to KeyAuth heartbeat calls. Offline grace caches signed with HMAC ensure zero downtime during extended outages.