✏️ Explanatory Question

How do timeouts, retries and circuit breakers protect a request flow?

👁 1 Views
📘 Detailed Answer
🟢 Easy
No previous question
No next question
💡

Answer with Explanation

Without these, one slow dependency stalls every thread and takes down the whole service.

Timeouts - never make an unbounded call. Set the timeout from the dependency's p99, not its average, and make the caller's timeout shorter than its own caller's, so budgets nest correctly.

Retries - only for idempotent operations, and always with exponential backoff plus jitter. Without jitter, all clients retry at the same instant and create a thundering herd that keeps the service down. Cap attempts at two or three; add a retry budget so retries never exceed a few percent of traffic.

Circuit breaker - tracks the failure rate. On crossing a threshold it opens and fails fast without calling the dependency, letting it recover. After a cooldown it goes half-open, letting a trial request through, and closes if that succeeds.

Add bulkheads - separate connection pools per dependency - so one failing downstream cannot consume every thread. And define graceful degradation: serve stale cache or a reduced response rather than an error.

No previous question
No next question