The 30 second answer
I assume every remote call can hang or fail. Every call gets a timeout, retries are limited and use exponential backoff with jitter, and only one layer retries. A circuit breaker stops calling a dependency that keeps failing, bulkheads keep one slow dependency from using up all threads or connections, and when something is down I degrade gracefully, for example by serving cached or partial results instead of an error.
Timeouts. The AWS Builders' Library calls timeouts a best practice for any remote call: without one, a slow dependency holds your threads and connections until you run out. AWS picks an acceptable rate of false timeouts, such as 0.1%, and sets the timeout at the matching latency percentile of the dependency (p99.9 in that example).
Retries with exponential backoff and jitter. Retries fix transient failures, but they add load exactly when a system is struggling. Exponential backoff waits longer after each failure, and jitter adds randomness so that clients who failed at the same moment don't retry at the same moment. Two warnings from AWS:
- Retry amplification. In their example, a five-deep call stack with three retries at each layer can multiply load on the database by 243 times when it starts failing. Their practice is to retry at a single point in the stack.
- Only retry what is safe. A retried write must be idempotent; see the idempotency question below.
Circuit breaker. Microsoft's pattern description has three states: Closed (calls pass and failures are counted), Open (after a failure threshold, calls fail immediately for a timeout period), and Half-Open (a few trial calls; success closes the breaker, failure opens it again). It stops wasting resources on a dependency that is down and gives it time to recover.
Bulkhead. Named after a ship's watertight sections: give each dependency its own thread pool, connection pool or instance group, so one slow dependency can only exhaust its own section, not the whole service.
Graceful degradation and load shedding. Google's SRE book lists serving degraded results as a way to avoid cascading failure, along with rejecting excess load early. AWS describes the goal in terms of goodput: requests handled without errors and fast enough to be useful, rather than raw throughput. Examples: show a product page without recommendations, serve a cached price with a check at checkout, or drop low-priority traffic first.
Common mistakes interviewers listen for.
- Retrying on every layer, or retrying without a cap and without jitter.
- A timeout longer than the caller's own timeout, so work continues after nobody is waiting.
- Treating a circuit breaker as a fix; it is protection while the real cause is fixed.
Sources (5)
- AWS Builders' Library: Timeouts, retries, and backoff with jitteraws.amazon.com
- Microsoft Azure Architecture Center: Circuit Breaker patternlearn.microsoft.com
- Microsoft Azure Architecture Center: Bulkhead patternlearn.microsoft.com
- Google SRE Book: Addressing Cascading Failuressre.google
- AWS Builders' Library: Using load shedding to avoid overloadaws.amazon.com