Skip to the page

Spring microservices · mid

Resilient calls: clients, timeouts, retries and circuit breakers

Every call between services needs timeouts, careful retries and a circuit breaker. A slow optional service must not take checkout down.

The notes

What you must know

  • OpenFeign is feature-complete with bug fixes only. For new work use Spring's HTTP interface clients on RestClient or WebClient.
  • Every call needs: connect and read timeouts that fit the caller's own deadline; retries only for idempotent calls, with backoff and jitter; a circuit breaker; and tests with WireMock or contract tests.
  • Resilience4j circuit breaker states: CLOSED (calls go through), OPEN (calls fail at once with CallNotPermittedException), HALF_OPEN (a few trial calls decide).
  • It opens when the failure rate or slow-call rate in the sliding window passes a threshold, after minimumNumberOfCalls. Windows are count-based or time-based. Slow calls count too.
  • Fallbacks: cached or default data for optional things. For payments fail clearly or queue for later. Never pretend a payment succeeded.
  • Review of a retry config: retrying a charge can charge twice unless the provider supports an idempotency key; retry only timeouts, connection errors, 503 and 429, not all exceptions; use exponential backoff with jitter and two or three attempts; avoid a 30-second timeout when the caller gives up at 10 seconds.
  • A breaker that needs 1,000 calls and 90 percent failures opens late or never. timelimiter applies only to async calls; for a blocking RestClient set the read timeout.
  • Slow optional dependency: calls with no read timeout hang, all 200 Tomcat threads wait, and checkout returns 503. Switch the call off with a feature flag first; more pods do not help. Design: timeouts on every call, a bulkhead (Resilience4j, or Framework 7's @ConcurrencyLimit) so one dependency uses only a few threads, a breaker, and a load test with fault injection.

The red pen

Common traps: mistake → fix

  • Mistake: Retry everything three times

    Fix: retrying non-idempotent calls repeats side effects.

  • Mistake: A circuit breaker replaces timeouts

    Fix: without timeouts slow calls never finish and the breaker cannot count them.

  • Mistake: More pods fix a slow dependency

    Fix: they add more waiting threads.

Easy to hard

Questions interviewers ask, easy to hard

  1. OpenFeign or HTTP interface clients in 2026?
  2. Explain the states of a circuit breaker.
  3. Review this retry and timeout config for POST /charges.
  4. A slow loyalty service takes checkout down. Why and what do you do?

Practise

Practise with these questions

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview