App basics: HTTP, auth, dataLesson 9 of 11
Making Service Calls Survive Failures
Every call between services crosses a network that can be slow or broken. Follow one checkout request while the payments service struggles, and see which patterns keep the rest of the system standing.
Time budget—
Calls to payments1
Breaker—
User sees200 OK
RequestResponse / reportWatchAppears in a later step
What you will learn
- Why one slow dependency spreads into a full outage
- Timeouts on every call, and one budget across hops
- Retries with backoff and jitter, and only for idempotent calls
- How retries at every layer multiply load
- Circuit breakers, bulkheads, load shedding and fallbacks
Patterns, and where they live
| Pattern | Protects | Typical setting | Watch out |
|---|---|---|---|
| Timeout | The caller from waiting forever | Per call, shorter than the caller's own timeout | Too long does nothing, too short fails healthy slow calls |
| Retry with backoff and jitter | Against brief failures | 2 to 3 attempts, exponential wait with random spread | Only idempotent requests, only in one layer |
| Retry budget | The callee from retry storms | Retries limited to a share of normal traffic | Retries silently stop when the budget is used up |
| Circuit breaker | The callee, and the caller's time | Failure ratio or count, cooldown, trial calls | Needs a fallback or a clear error for the open state |
| Bulkhead / pool limit | Other dependencies of the same caller | Max connections and pending requests per upstream | Too small rejects normal peaks |
| Load shedding / rate limit | The service itself | 429 or 503 with Retry-After | Clients must honor it |
| Fallback | The user experience | Cache, default value, queue for later | Must not depend on the failing part |
| Where | Examples | Good for | Limits |
|---|---|---|---|
| Client library | resilience4j, Polly, gRPC retry and deadline settings | Knows which calls are idempotent and what fallback makes sense | Must be done in every language and service |
| Service mesh | Istio VirtualService retries and timeouts, DestinationRule connection pools and outlier detection, Linkerd retries and budgets | Same policy for every service, no code changes | Does not know business meaning; fallbacks stay in code |
| Proxy or gateway | Envoy, nginx, HAProxy, API gateways | One place at the edge, rate limits per client | Sees only its own hop |
Pick one layer for retries. A mesh that makes 3 attempts in front of a client library that also makes 3 attempts is the retry storm from step 6.
Try it yourself
# A timeout on one call: 2 s to connect, 5 s for the whole request
curl -sS -o /dev/null -w '%{http_code} %{time_total}s\n' --connect-timeout 2 --max-time 5 https://example.com/
# curl's own retries: transient errors (timeouts, 408, 429, 500, 502, 503, 504),
# waiting 1 s then doubling; --retry-max-time caps the total time
curl -sS -o /dev/null --retry 3 --retry-max-time 20 https://example.com/
# See rate limit and Retry-After headers a server sends
curl -sSI https://example.com/ | grep -i -E 'retry-after|ratelimit'
# With Istio: retries, timeouts, pool limits and outlier detection per service
kubectl get virtualservice -A -o yaml | grep -E -A4 'retries:|timeout:'
kubectl get destinationrule -A -o yaml | grep -E -A6 'connectionPool:|outlierDetection:'
Check yourself
Further reading: Timeouts, retries and backoff with jitter (AWS Builders' Library) · Circuit breaker (Martin Fowler) · Envoy circuit breaking · gRPC deadlines · Service Mesh ② Splitting Traffic · Reverse Proxies and Load Balancing · Designing HTTP APIs