Scrivio Interview library
DesignAdvanced6 min read · updated 12 November 2026

Your services use a mix of Spring Retry, Resilience4j and hand-written loops. Framework 7 now offers built-in retry and concurrency limits. What standard would you set?

I would make Framework 7's built-in @Retryable and @ConcurrencyLimit the default for simple retries and concurrency limits, since they need no extra dependency, and keep Resilience4j for circuit breakers, bulkheads, rate limiters and their rich metrics, which the core features do not replace. Spring Retry is in maintenance mode, so we stop adding it and migrate off it as services are touched, and hand-written loops are removed. The standard lives in a shared starter with defaults for attempts, backoff, jitter and timeouts, requires idempotency for every retried call, and makes retries visible in metrics so retry storms show up on dashboards.

Why this question is asked

When a company has three ways of retrying, it usually has three different sets of defaults too: one service retries five times with no delay, another retries forever with a fixed second, and a hand-written loop somewhere swallows the last exception. During an outage these differences are what turn a slow dependency into a cascading failure. Framework 7 adding retry to the core framework is a good moment to set a standard. Interviewers ask this design question to see whether we know what each tool is good for, and whether a standard covers behaviour, not just library choice. In this answer, we will recap the tools, decide which one covers what, define the shared defaults, set the safety rules, and make retries observable.

1A Quick Recap of the Three Approaches

Spring Retry is a separate Spring project that has provided @Retryable, @Recover and RetryTemplate for years. It is now in maintenance mode, because its core ideas moved into Spring Framework 7. Resilience4j is a broader fault-tolerance library: besides retry, it has a circuit breaker, which stops calling a failing service for a while, a bulkhead, which limits concurrent calls so one dependency cannot use all our threads, a rate limiter and a time limiter, all with Micrometer metrics. Hand-written loops are for and while blocks around a call with a Thread.sleep, which nearly always lack jitter, a total time limit and metrics.

Framework 7's built-in features are @Retryable and @ConcurrencyLimit in org.springframework.resilience.annotation, enabled with @EnableResilientMethods, and a programmatic RetryTemplate in org.springframework.core.retry.

2Which Tool Covers What

The decision is not one library for everything. The core features cover the most common need, retrying a call with backoff and limiting concurrency, with no extra dependency and with the same proxy model as the rest of Spring. When a service needs to stop calling a dependency that is clearly down, or to rate-limit itself, Resilience4j is still the right tool.

Who does what in the standard
NeedStandard toolWhy
Retry with backoffFramework 7 @Retryable or RetryTemplatecore, no extra dependency
Limit concurrent calls@ConcurrencyLimit, or a Resilience4j bulkheadcore for simple cases
Circuit breakerResilience4jnot provided by the core framework
Rate limiter, time limiterResilience4jnot provided by the core framework
Existing Spring Retry codemigrate when the service is changedSpring Retry is in maintenance mode
Hand-written retry loopsremoveno jitter, no limits, no metrics

3Defaults in a Shared Starter

Teams should not choose numbers from scratch every time. A small platform starter provides named retry profiles, so a team writes one line and gets tested values. A sensible default profile for a synchronous call between internal services is three retries at most, an initial delay of 100 ms, a multiplier of 2, jitter of about 50 percent of the delay, a maximum delay of 1 second, and a per-attempt timeout of 1 to 2 seconds set on the HTTP client. That keeps the worst case under the caller's own deadline.

Properties
# acme-resilience-starter defaults (illustrative)
acme.retry.profiles.internal-http.max-retries=3
acme.retry.profiles.internal-http.delay=100ms
acme.retry.profiles.internal-http.multiplier=2
acme.retry.profiles.internal-http.jitter=50ms
acme.retry.profiles.internal-http.max-delay=1s
acme.retry.profiles.internal-http.attempt-timeout=2s
# Worst case: 4 attempts x 2 s + waits of about 0.1 + 0.2 + 0.4 s -> about 8.7 s
# So the caller's own timeout must be larger, or retries must be fewer

Notice the last comment. Retry budgets add up across layers: if a gateway retries three times, and the service behind it retries three times, and the service behind that does too, one user request can produce 64 calls to the deepest service. The standard therefore says that only one layer retries a given call, normally the one closest to the failing dependency.

4The Safety Rules

Two rules are non-negotiable. First, every retried call must be idempotent, meaning that repeating it has no extra effect. Reads are idempotent; a payment POST is not, unless it carries an idempotency key that the server uses to ignore duplicates. Second, only transient failures are retried: connection errors, timeouts, 503 and 429 with Retry-After. A 400 or a validation error will fail the same way forever.

Code review checks these rules, and the starter helps by providing exception sets, such as a transient-http set, instead of letting each team list exception classes by hand.

Step throughShould this call be retried?
  1. Is the operation idempotent?
    YesCheck the failure typeNoAdd an idempotency key or do not retry
  2. Is the failure transient?
    YesRetry with the standard profileNoFail fast, map to a domain error
  3. Does another layer already retry?
    YesRetry in one layer onlyNoKeep this retry
  4. Is the dependency often down for minutes?
    YesAdd a Resilience4j circuit breakerNoRetry alone is enough

4 steps in order. Play them, or step through them one at a time.

5Making Retries Visible

A retry that succeeds hides a problem: users see no error, but a dependency is failing a fifth of the time. So retries must be counted. Resilience4j publishes retry metrics through Micrometer out of the box. For the core features, the starter registers a retry listener that increments a counter, for example retry.attempts tagged with the target service and outcome; check which listener hooks your Framework version offers.

With that metric on the service dashboards, a retry storm, a sudden rise in retries across many callers, becomes visible within a minute, and an alert on the ratio of retries to calls catches a degrading dependency before it fails completely.

6Follow-up questions

Why not standardise on Resilience4j for everything?

We could, and it is a defensible choice. But for the common case of a simple retry, the core features need no extra dependency, use the same annotations style as the rest of Spring and will be maintained with the framework. Keeping Resilience4j for what only it does keeps most services simpler.

How do you migrate Spring Retry code?

When a service is next changed, replace org.springframework.retry.annotation.Retryable with the core annotation, @EnableRetry with @EnableResilientMethods, and map attributes such as backoff to delay and multiplier. @Recover methods have no direct equivalent in the core annotation, so the fallback moves into the caller's exception handling. Tests that force a failure prove the new retry still triggers.

What is a retry storm?

It is the extra load created when many clients retry against a dependency that is already struggling. If a service is slow because it is overloaded, three retries per caller can quadruple its load and keep it from recovering. Small retry counts, jitter, one retrying layer and circuit breakers all exist to prevent it.

7Conclusion

In this answer, we set a retry standard rather than a single library. Framework 7's @Retryable, @ConcurrencyLimit and RetryTemplate become the default for simple retries and limits, Resilience4j stays for circuit breakers, bulkheads and rate limiters, Spring Retry is retired gradually because it is in maintenance mode, and hand-written loops go. A shared starter provides tested defaults for retries, backoff, jitter and timeouts, every retried call must be idempotent and transient-only, and retry metrics make storms visible.

What to say in the interviewAbout 80 seconds aloud

Open with

I would set a standard about behaviour first and libraries second. For simple retries with backoff and for limiting concurrency, the default becomes Framework 7's built-in @Retryable and @ConcurrencyLimit, or RetryTemplate in code, because they need no extra dependency and follow the normal Spring proxy model.

Then, if they want more

Resilience4j stays for what the core does not offer: circuit breakers, bulkheads, rate limiters and their metrics. Spring Retry is in maintenance mode, so no new usage, and we migrate services off it as we touch them. Hand-written loops get removed, because they almost never have jitter, limits or metrics.

Then a small shared starter gives named profiles with tested defaults, say three retries, 100 milliseconds initial delay doubling with jitter, a one second cap and a two second per-attempt timeout, so the worst case stays under the caller's deadline.

Two rules are mandatory: only idempotent operations are retried, or they carry an idempotency key, and only transient failures like timeouts, connection errors, 503 and 429 are retried. Only one layer retries a given call, to avoid multiplying load.

Finally every retry is counted in a metric tagged by target and outcome, so a retry storm or a quietly degrading dependency shows up on dashboards and alerts.

About this answer

Last updated
12 November 2026
Versions it names
Spring Framework 7
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your services use a mix of Spring Retry, Resilience4j and hand-written loops. Framework...": https://scrivio-interview-library.netlify.app/spring-boot/spring-framework-evolution/c42009b863/