Why does every outbound call need a timeout, and how do you retry correctly with backoff and jitter?
Short answer
Without timeouts, a hung dependency holds threads forever; pools are finite (Tomcat defaults to 200), so even unrelated APIs die. Retry only transient errors, never errors caused by the request, and retry with capped exponential backoff and jitter.
3 points to say:
- Always set timeouts: short connect (1–2 seconds), read based on the other side's p99, plus an overall deadline across retries.
- Retry only transient errors (timeouts, connection errors, 429, 502–504); retry writes only when surely idempotent.
- Exponential backoff + full jitter prevents a thundering herd; retry at one layer with a retry budget (3 layers × 3 tries = 27 calls).
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.