Quick revision
The short answer
The standard says that every HTTP and database client has a connect timeout, a read timeout and a pool acquisition timeout, with no infinite values anywhere, and that retries happen only for idempotent calls, a few times, with jittered backoff, at one layer. Each request carries its remaining time budget in a header so downstream calls never outlive the caller. We make it the default by shipping it inside the platform starter's client builders, failing the build or startup when a client has no timeout, and publishing timeout and retry metrics per dependency.
What to remember
In this answer, we built a timeout and retry standard for 60 services. Every client gets a connect, read and pool acquisition timeout with no infinite values, retries are limited to idempotent calls with jittered backoff at a single layer, and a remaining-time header lets every hop respect the user's deadline. We ship it in the platform starter's builders, enforce it with build rules and a startup check, and prove it with per-dependency metrics.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The standard says that every HTTP and database client has a connect timeout, a read timeout and a pool acquisition timeout, with no infinite values anywhere, and that retries happen only for idempotent calls, a few times, with jittered backoff, at one layer. Each request carries its remaining time budget in a header so downstream calls never outlive the caller. We make it the default by shipping it inside the platform starter's client builders, failing the build or startup when a client has no timeout, and publishing timeout and retry metrics per dependency.
Why this question is asked
With 60 services, almost every outage that spreads starts the same way: one dependency gets slow, callers wait forever because a client had no timeout, threads and connections pile up, and the slowness travels up the call chain. Interviewers ask this design question to see whether we can turn resilience into a default that teams get without trying. In this answer, we will look at what the standard must contain for timeouts, retries and deadlines, how to ship it as code in a platform starter, how to enforce it, and which metrics prove that it works.
1A Quick Recap of the Three Timeouts Every Client Needs
A remote call can get stuck in three different places, and each needs its own limit. The connect timeout limits how long we wait to open a TCP connection. If the host is down or a firewall drops packets, without it we can wait for the operating system default, which is often more than a minute. The read timeout (also called socket or response timeout) limits how long we wait for bytes once connected. The pool acquisition timeout limits how long we wait to borrow a connection from our own pool when all connections are busy.
The third one is easy to forget. HikariCP, the default database pool in Spring Boot, waits 30 seconds by default for a free connection, which is far longer than any user will wait. Several common clients have no limit at all by default: the JDK HttpClient has no request timeout unless we set one, and older RestTemplate setups using the simple request factory wait forever. So the first rule of the standard is simple: no client may rely on library defaults, and no value may be infinite.
| Client | Connect | Read or query | Pool acquire |
|---|---|---|---|
RestClient / WebClient | 1 s | per dependency, default 2 s | 500 ms |
| JDBC via HikariCP | 1 s (driver) | statement timeout, default 5 s | connectionTimeout 1 s |
| Redis (Lettuce) | 500 ms | command timeout 500 ms | 500 ms if pooled |
| Kafka producer | n/a | delivery.timeout.ms set explicitly | max.block.ms 1 s |
2Retry Rules That Do Not Multiply Load
The second part of the standard covers retries. A retry is useful only when the failure is transient, such as a connection reset, a timeout or an HTTP 503, and only when repeating the call is safe. So the default policy retries only idempotent operations (GET, PUT, DELETE, or a POST that carries an idempotency key), makes at most 3 attempts in total, waits with exponential backoff and full jitter, for example 100 ms then 200 ms with a random spread, and never retries 4xx responses.
The rule that matters most at scale is retry at one layer. If the gateway, service A and service B each make 3 attempts, one user click can turn into 27 calls to the bottom service during an incident. The standard therefore says that retries happen in the client closest to the failing dependency, and that every service which receives a retried request does not retry again on its own. A retry budget, for example at most 10 percent extra traffic, keeps a dependency in trouble from getting more load.
3Deadline Propagation Across Hops
Timeouts set per client still have a gap. If the user's request has 2 seconds in total and service A has already used 1.8 seconds, there is no point in A calling B with a 2 second read timeout. B will do work nobody is waiting for. A deadline fixes this: the edge decides how long the whole request may take, and every hop passes the remaining time along.
The standard defines the header precisely. We prefer a relative budget in milliseconds, such as X-Request-Budget-Ms: 1800, over an absolute timestamp, because an absolute time depends on clocks being in sync across machines. Each service reads the header when the request arrives, turns it into a local deadline, and for every outgoing call uses the smaller of its configured read timeout and the remaining time minus a safety margin of about 50 ms. If the budget is already spent, it answers at once with 504 instead of starting work.
Notice that Deadline here is a small class in our own starter, not a Spring type.
4Shipping the Standard Inside the Platform Starter
A standard becomes the default when teams get it by adding one dependency. We publish a platform starter, a Spring Boot auto-configuration jar, that provides pre-configured RestClient.Builder and WebClient.Builder beans with connect, read and pool timeouts already set, a HikariCP configuration with a short connectionTimeout and a statement timeout, the deadline filter and header propagation, and Resilience4j retry and circuit breaker defaults per named dependency. Teams who inject RestClient.Builder instead of calling RestClient.create() get our settings automatically, and recent Boot versions also have properties for HTTP client timeouts (check your version for the exact names).
Teams declare their dependencies in configuration, for example platform.clients.inventory.read-timeout=800ms, and the starter builds the client, the retry and the metrics tags from that one entry.
5Enforcing It: Fail the Build or Fail Startup
Defaults alone are not enough, because someone will still write new RestTemplate() in a hurry. We enforce in two places. In the build, an ArchUnit rule (a library that tests code structure) fails the tests when code calls RestClient.create(), HttpClient.newHttpClient() or new RestTemplate() directly. At startup, a check in the starter inspects every client and pool bean and refuses to start when one has no timeout or an infinite one.
Failing early is kinder than it sounds: a refused startup in a test environment costs ten minutes, an infinite timeout in production can cost an outage.
6Metrics That Show Whether the Standard Works
Finally, the starter publishes the same metrics for every dependency, tagged with the dependency name: request latency percentiles, the count of timeouts by type (connect, read, pool), the count of retries and whether the retry succeeded, and the pool's pending threads. Resilience4j and HikariCP already expose most of these through Micrometer.
Each quarter, the platform team reviews these dashboards with service owners and adjusts the defaults from real data instead of guesses.
- Team adds the platform starterone dependency
- Team names the dependency
platform.clients.inventory - Starter builds the clienttimeouts, retry, deadline, metrics
- Client created by hand?YesArchUnit test fails the buildNoBuild passes
- Any timeout missing at startup?YesService refuses to startNoService starts
- Dashboards show timeouts and retriesper dependency
6 steps in order. Play them, or step through them one at a time.
7Follow-up questions
Why not just let each team choose its own timeouts?
Teams should choose the values for their own dependencies, because only they know that the reporting API takes 3 seconds and inventory takes 50 ms. What they should not choose is whether a timeout exists. The standard fixes the structure (every client has three limits, retries follow one policy, deadlines are honoured) and provides sensible defaults, and teams override values with a short written reason.
How do you pick the read timeout value for a dependency?
From measurement. We look at the dependency's latency distribution and set the timeout a little above its p99.9, for example 800 ms when p99.9 is 600 ms, and below what our own caller is willing to wait. If the timeout ends up larger than our own budget, that tells us the design needs to change, for example by making the call asynchronous.
8Conclusion
In this answer, we built a timeout and retry standard for 60 services. Every client gets a connect, read and pool acquisition timeout with no infinite values, retries are limited to idempotent calls with jittered backoff at a single layer, and a remaining-time header lets every hop respect the user's deadline. We ship it in the platform starter's builders, enforce it with build rules and a startup check, and prove it with per-dependency metrics.
Open with
I would write the standard as code, not as a document. It has four parts. First, every client, HTTP, JDBC, Redis or Kafka, must have a connect timeout, a read or statement timeout and a pool acquisition timeout, and nothing may be infinite; HikariCP's 30 second default wait, for example, would be cut to about a second.
Then, if they want more
Second, retries: only for transient failures on idempotent calls or calls with an idempotency key, at most three attempts, exponential backoff with jitter, and only at one layer, usually the client nearest the failing dependency, with a retry budget so retries add at most about ten percent of traffic.
Third, deadline propagation: the edge sets a budget and each hop passes the remaining milliseconds in a header, uses the smaller of its configured timeout and the remaining time, and returns 504 immediately when the budget is gone. Fourth, metrics per dependency: timeouts by type, retries and whether they helped, and pool waiting threads.
To make it the default, I would put all of this into the platform starter, so teams inject the pre-built RestClient builder and data source and only declare per-dependency values. Then I would enforce it with an ArchUnit rule that fails the build on hand-made clients and a startup check that refuses to start when a timeout is missing.
Finally, I would review the dashboards with teams regularly and tune the defaults from real latency data.
About this answer
- Last updated
- 12 November 2026
- 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.
- Official documentation
- Spring Cloud documentation, Resilience4j documentation
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 "Define a timeout and retry standard for all HTTP and database clients used by 60 Spring...": https://scrivio-interview-library.netlify.app/spring-boot/resilience/1c835029e0/