What is Retry Pattern
Retrying on failures
Retry Pattern is a design pattern for handling transient failures by automatically retrying failed operations.
When to Use
- Temporary network errors
- Timeouts when calling external services
- Database connection errors
- API overload (429 Too Many Requests)
- Temporary service unavailability
Retry Strategies
- Immediate retry — no delay
- Fixed delay — equal intervals
- Linear delay — increment by constant
- Exponential backoff — doubling time
- Jitter — adding randomness
Key Parameters
- Maximum number of attempts
- Initial delay
- Maximum delay
- Backoff multiplier
- List of retryable errors
Best Practices
- Log all retry attempts
- Use Circuit Breaker together
- Limit number of attempts
- Add jitter to distribute load
- Consider operation idempotency