Programming/Error/Handling/Retry Logic/Exponential Backoff
Properties
- tags
- Programming, Error Handling, Retry Logic, Algorithm
- alias
- Exponential Backoff
Exponential Backoff
- A retry strategy where the delay between retry attempts increases exponentially
Key Concepts
Common Use Cases
Benefits
Example Formula
delay = min(max_delay, initial_delay * (base ^ attempt_number))- For base=2:
- Note:
- The key property of exponential backoff is multiplicative growth of the wait-time:
Displayed: t_n = t_0 \times f^{\,n},
whereInline: f>1is a constant factor andInline: nis the retry count.
Doubling (Inline: f = 2) yields the classic binary-exponential sequence
Displayed: 1\text{ s} \;\to\; 2\text{ s} \;\to\; 4\text{ s} \;\to\; 8\text{ s} \;\dots
which is what the code does withdelay = initial_delay * (base ^ attempt_number).
Multiplying by a fixed constant on each failure therefore produces the exponential curveInline: t_n = t_0\,2^{\,n}.
- The key property of exponential backoff is multiplicative growth of the wait-time:
Implementation Examples
- LangChain/Blog/25/04/17 LangChain Python Improved Content Blocks Retry Logic and More - LangChain's Runnable.with_retry implementation
See also