Patterns for automatically retrying failed carrier API requests without causing harm.
Exponential backoff with jitter is the standard retry strategy. Start with a 1-second delay, double it each retry, and add random jitter (0–50% of the delay) to prevent thundering herd.
Key rules:
- Never retry 4xx errors (except 429 Too Many Requests)
- Always retry 502, 503, 504
- Cap retries at 5 attempts
- Use a circuit breaker to stop retrying if the carrier is consistently failing
- For POST requests, always use an idempotency key when retrying