Skip to content

Lesson 2 of 13 · 15m

A Timeout Is Not an Answer

A timeout tells you a response did not arrive — retry discipline is what decides whether that ambiguity becomes a duplicate charge or a retry storm.

When your HTTP client reports a timeout, the only thing established is that a response did not arrive in the budget. The request may never have left — the connect call may have died in the kernel. It may be sitting in a socket buffer on the far side, unprocessed. Or it may have committed, and the response is the packet that got dropped. You cannot distinguish these cases, and neither can anyone else: this is the Two Generals problem, and it is not a metaphor, it is a proof that no finite exchange over an unreliable channel produces agreement that the last message was heard.

This is why "the request failed" is not a state the network gives you. It is a state your application chooses.

Timeouts are per-phase and usually absent

Most HTTP clients ship with no timeout at all. Python's requests.get(url) will wait as long as the kernel lets it — and the kernel is patient: tcp_syn_retries defaults to 6 on Linux, so a dead IP holds a connect() for roughly 127 seconds before ETIMEDOUT. The requests API takes a tuple: timeout=(connect_timeout, read_timeout), and those are different failures. A connect timeout says the peer is unreachable. A read timeout says the peer is alive and did not answer — the ambiguous case, the one where your request may have already done its damage.

gRPC is better designed than most here. A deadline set on the client is serialized into the grpc-timeout header on the wire, so the server knows the caller's remaining budget, can fail fast with DEADLINE_EXCEEDED before doing work that will be discarded, and can pass the remaining budget on to its own downstream calls. Deadline propagation is the point: a 300 ms budget is meaningless if the middle service fans out with a fresh 2-second timeout on each hop. Every hop subtracts; nothing refreshes.

The wrong mental model

"Retry until it succeeds" is the default a junior writes and an incident exploits. A fixed-interval retry is a metronome: when the dependency degrades, every caller retries on the same schedule, load multiplies by the retry count, and the dependency — which was merely slow — is now also busy answering requests that are about to time out. This is retry amplification, and it converts partial failure into total failure on a timer.

The metastable-failures literature (Bronson et al., HotOS 2021) names this precisely: a trigger plus a sustaining effect. The trigger can clear and the system stays saturated, because the retries themselves became the load. Your retry policy is a sustaining effect waiting for a trigger.

The fix is known and boring. Exponential backoff spreads attempts over increasing windows; jitter desynchronizes the metronome across callers. The AWS architecture blog's 2015 formula — full jitter, sleep = random_between(0, min(cap, base * 2 ** attempt)) — is what every AWS SDK implements, because synchronized retries against a recovering service are how you keep it down.

What to actually do

Give every outbound call a deadline, and make it a real number derived from the dependency's p99, not a round 30 seconds inherited from nothing. Propagate the remaining budget across hops: use gRPC deadlines where you have them, a X-Deadline header where you do not. Retry with exponential backoff and full jitter; cap total attempts and total elapsed time. Hedge reads where it helps — "The Tail at Scale" (Dean & Barroso, CACM 2013) sends a second request at the p95 latency mark — but only against idempotent operations, because a hedged write is a duplicate write. And before any retry of a non-idempotent operation, attach an idempotency key, because the next lesson is about why the far side owes you a dedup window for exactly this ambiguity.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.