Retry with a budget
Repeat transient work without multiplying damage.
The problem and the pattern
A short network interruption may justify retrying a read. Invalid input or a permission denial will not improve with repetition. Bound attempts, add backoff with jitter, honor the operation deadline, and verify that a write is safe to repeat before retrying it.
Follow the flow
Make it concrete
This excerpt isolates the concept. Connect it to the booking API as you work through the exercise.
Attempt 1 → transient failure
Wait: bounded exponential backoff + jitter
Attempt 2 → success
Stop when total deadline or attempt budget is exhaustedTrade-offs
- Retries improve resilience only for appropriate transient failures.
- They consume latency and downstream capacity.
- Use a single policy owner where possible and expose retry metrics.
When to avoid it
Avoid retrying non-idempotent writes when the previous result is unknown.
Your turn
A handler, repository, and HTTP client each retry three times. What can happen to downstream load?
Reveal a worked answer
Nested policies can multiply attempts rather than add them. Put retry ownership at a deliberate boundary, propagate one deadline, and measure total attempts and latency. A retry storm can turn a short outage into overload.