Exponential backoff with jitter for retries

14860
0

Immediate retries are a great way to stampede a struggling dependency. I use exponential backoff with jitter so retries spread out naturally and don’t synchronize across instances, and I cap the maximum delay so worst-case latency doesn’t become unbounded. The practical detail is deciding what to retry: only idempotent operations and only on transient errors (timeouts, 5xx, rate limits, 429). When errors are permanent (4xx that aren’t 429), I fail fast. This tiny utility gets reused everywhere—HTTP clients, queue consumers, even UI polling—and it improves reliability without changing business logic.