Quick revision
The short answer
I would make explicit timeouts mandatory for every outbound client and forbid infinite or library defaults, then make the safe path the easy one: a company starter that configures every client with sensible defaults and requires per-dependency values in configuration. I would enforce it with build-time checks and startup validation that fail when a client has no timeouts, pair timeouts with circuit breakers and bulkheads tested by fault injection, and review the timeout budget of each critical user journey end to end.
What to remember
In this answer, we turned repeated outages into a standard of mandatory, explicit, per-dependency timeouts based on measured latency, delivered through a company starter that makes the safe path the easy one. We enforced it with ArchUnit rules at build time and validation at startup, rolled it out in report mode first, paired timeouts with circuit breakers and bulkheads proven by fault injection, and reviewed timeout budgets end to end for the critical user journeys.
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.
I would make explicit timeouts mandatory for every outbound client and forbid infinite or library defaults, then make the safe path the easy one: a company starter that configures every client with sensible defaults and requires per-dependency values in configuration. I would enforce it with build-time checks and startup validation that fail when a client has no timeouts, pair timeouts with circuit breakers and bulkheads tested by fault injection, and review the timeout budget of each critical user journey end to end.
Why this question is asked
After several cascading outages with the same root cause, a reminder email will not fix anything; the next new service will make the same mistake. Interviewers ask this question to see how a senior engineer turns a lesson into a mechanism that works across 100 services and many teams without becoming a bureaucratic burden. In this answer, we will look at why the outages keep happening, define the standard, build it into a starter, enforce it automatically, add the resilience patterns that make timeouts effective, and close with end-to-end budget reviews for the journeys that matter most.
1Why Missing Timeouts Keep Causing Outages
A cascading outage is one where a failure in one service spreads to services that depend on it. With HTTP calls the mechanism is simple: a dependency gets slow, callers wait, waiting calls hold threads and connections, the caller runs out of both and stops answering, and its own callers start waiting. Missing or very long timeouts are what let the waiting last long enough to spread.
They keep happening because the default is often unsafe. Several popular clients historically had no read timeout or one measured in minutes, and a developer who writes RestClient.create() or new OkHttpClient() gets whatever the library chose. The code works in every test, because test dependencies answer quickly. The problem only appears in production, under load, on a bad day. So the fix has to work without relying on every developer remembering.
2Defining the Standard
The standard should be short enough to remember. Every outbound client must have explicit connect, read or response, and connection-acquire timeouts; library defaults and infinite values are not allowed. Every value is set per dependency in configuration, not hard-coded, so it can be tuned without a release. Inner timeouts must fit inside the caller's budget. And values come from measured latency, roughly the dependency's p99 with some headroom, reviewed when latency changes. We publish it with the reasons and the incident numbers, because engineers follow rules they understand much more reliably than rules they are handed.
3Shipping a Company Starter
A Spring Boot starter is a dependency that auto-configures beans when it is on the classpath. Our starter provides a customised RestClient.Builder and WebClient.Builder that every team uses, with defaults such as a 1 second connect timeout, a 200 ms pool-acquire timeout and a read timeout that must be set per dependency. Dependencies are declared in configuration, which makes timeouts visible in one place per service.
Notice that the starter refuses to guess the read timeout, the one value that really depends on the dependency. Connect and acquire timeouts have safe defaults because they rarely vary much inside a data centre. That split keeps configuration small while forcing a conscious decision where it matters.
4Enforcing It Automatically
Rules in a wiki decay; rules in the build last. We enforce the standard in two places. At build time, an ArchUnit test (a library that checks code structure in a unit test) shared by all services fails if code constructs HTTP clients directly instead of through the starter, for example calls to RestClient.create() or new OkHttpClient(). At startup, the starter validates its configuration and refuses to start if a declared client has no read timeout, or if a timeout exceeds a ceiling such as 30 seconds.
- Developer adds a client
- Built through the starter?YesNext checkNoArchUnit test fails the build
- Read timeout configured?YesService startsNoStartup validation fails
- Fault injection in stagingslow dependency must not cascade
- Production metrics and alerts
5 steps in order. Play them, or step through them one at a time.
A service that breaks the rule fails in its own pipeline, before any review and long before production. For the existing 100 services, we run the same checks in report-only mode first, publish the list of violations per team, and switch to failing once the count reaches zero, so the enforcement does not block everyone on day one.
5Pairing Timeouts With Circuit Breakers and Bulkheads
A timeout limits how long one call waits; it does not stop us from making thousands of calls that each wait that long. So the starter also offers two patterns. A circuit breaker counts failures to a dependency and, when they cross a threshold such as 50 percent of the last 100 calls, stops calling it for a while and fails immediately, giving it time to recover. A bulkhead limits how many concurrent calls one dependency may have, for example 20, so a slow dependency cannot take every thread in the service. Resilience4j provides both and integrates with Spring Boot.
We prove the whole setup works with fault injection: in staging, and later in controlled production game days, we add latency or errors to a dependency with a tool such as Toxiproxy or the service mesh, and check that the caller degrades as designed instead of failing completely.
6Reviewing Budgets per Critical Journey
Per-service rules do not guarantee that a whole request path is consistent. For the handful of journeys that matter most, such as login, search and checkout, we draw the call graph, write down each hop's timeout and retries, and check that they nest inside the user-facing deadline. We do this review once when the standard launches and again when a journey's architecture changes. These reviews often find the worst problems, such as a 30 second inner timeout under a 3 second page budget, that no single team could see.
7Follow-up questions
How do you handle the 100 existing services?
Gradually and visibly. Run the checks in report mode, give each team its list of violations and a deadline, fix the highest-traffic and most critical services first, and only then make the checks fail builds. A dashboard of compliance per team keeps the work visible without blame.
What if a team really needs a very long timeout?
They declare it explicitly in configuration with a comment, and the startup ceiling can be raised for that client with an override that shows up in review. Usually the discussion reveals that the call should be asynchronous, which is the better fix.
Would a service mesh make the starter unnecessary?
It helps, because the mesh can enforce timeouts for every call regardless of language. But the application still needs to know its deadline to stop work early and to decide on fallbacks, and mesh timeouts must nest with application timeouts. I would treat the mesh as a backstop, not a replacement.
8Conclusion
In this answer, we turned repeated outages into a standard of mandatory, explicit, per-dependency timeouts based on measured latency, delivered through a company starter that makes the safe path the easy one. We enforced it with ArchUnit rules at build time and validation at startup, rolled it out in report mode first, paired timeouts with circuit breakers and bulkheads proven by fault injection, and reviewed timeout budgets end to end for the critical user journeys.
Open with
I would start by treating it as a systems problem, not a discipline problem: the defaults in many clients are infinite or very long, and code without timeouts passes every test, so people will keep making the mistake unless the platform prevents it.
Then, if they want more
The standard itself is short: every outbound client has explicit connect, read and connection-acquire timeouts, set per dependency in configuration, based on measured latency, and nested inside the caller's budget.
Then I would make that the easy path with a company starter that hands out pre-configured RestClient and WebClient builders, gives safe defaults for connect and pool-acquire timeouts, and requires the read timeout to be declared per dependency.
To enforce it, I would add a shared ArchUnit rule that fails the build if someone creates a raw client, and startup validation that refuses to start without a read timeout or with one above a ceiling. For the existing services I would run that in report mode first, fix the critical ones, then switch it to failing.
Timeouts alone do not stop thousands of waiting calls, so the starter also offers circuit breakers and bulkheads, and we test the whole thing with fault injection in staging. Finally, for login, search and checkout, I would review the full timeout chain end to end.
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 Framework reference, Spring Web MVC
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 "After several cascading outages caused by missing or very long HTTP timeouts, how would...": https://scrivio-interview-library.netlify.app/spring-boot/http-clients/d458e2307c/