Skip to content
Commitwise
Menu

A service you own calls three other services. How do you make it resilient to their failures?

BackendSenior

In shortGive every call a timeout from a latency budget, retry only transient failures of idempotent calls with backoff and jitter at one layer, wrap each dependency in a circuit breaker and a bulkhead, define fallbacks that degrade explicitly, run independent calls in parallel, and observe all of it.

Model answer

Classify dependencies: required (the request fails without it), important (a degraded answer is acceptable), optional (the feature can disappear). Resilience settings follow from that.

Timeouts first: every call gets connect and read timeouts derived from your own latency budget (if your p99 target is 800 ms, a dependency can’t have 5 s). Propagate deadlines downstream where possible. Default HTTP clients often have no read timeout.

Retries, carefully: only for transient errors (connection resets, 503s, timeouts on idempotent calls), only for idempotent operations or with idempotency keys, with exponential backoff and jitter, two or three attempts, at one layer. Retries multiply across layers and cause retry storms.

Circuit breakers: per dependency, on failure and slow-call rates; open breakers fail fast and send traffic to the fallback, giving the dependency time to recover.

Bulkheads: cap concurrent calls per dependency so one slow service can’t consume all threads or pool connections (still relevant with virtual threads).

Fallbacks: explicit and honest: cached data with a staleness limit, “availability unknown”, or hiding an optional widget. Required dependencies fail fast with a clear error rather than pretending.

Structure and proof: run independent calls in parallel; expose breaker states, retry counts and fallback rates as metrics with alerts; and test with fault injection (latency and errors per dependency) in load tests. Resilience4j provides the building blocks in Spring Boot.

What they're looking for

Timeouts as the first line, retry discipline (idempotency, backoff, jitter, single layer, retry budgets), circuit breakers and bulkheads with reasons, explicit fallbacks per dependency criticality, parallel calls, metrics and fault-injection testing.

Common mistakes

  • Retries without timeouts or idempotency.
  • The same fallback for required and optional dependencies.
  • No way to see breaker state or fallback rate in production.

More backend questions

Esc

Type to search the whole site.