Every service in your estate uses the client library's default timeout of 30 seconds. Why is that dangerous, and what would you set instead?
Show the full answer Hide the answer
What the interviewer is testing
Whether you can connect timeout configuration to resource occupancy and cascading failure.
Why it is dangerous
Little's Law: in-flight requests equal arrival rate times latency. If a dependency slows from 50 ms to 30 seconds, occupancy rises 600-fold. The caller's thread or connection pool exhausts within seconds.
Once the pool is exhausted, the service cannot serve any request, including ones that never touch the slow dependency — which is why services that do not call it also fail. A partial failure has become a total one.
A 30-second timeout also means the caller is waiting long after the user has given up, consuming capacity to produce an answer nobody will read.
What to set instead
Derive it from the dependency's observed latency distribution, not from a default. A reasonable starting point is around the p99.9 plus a margin — so a dependency with a p99 of 80 ms gets a timeout in the region of 250 to 500 ms, not 30 seconds.
The principle: a timeout should be short enough that exhausting the pool takes longer than your detection and mitigation, and long enough that normal slow requests are not cut.
The better mechanism
Deadline propagation rather than independent per-hop timeouts. A budget is set at the edge and carried through the call chain; each service passes the remainder onward and fails fast if the budget is already exhausted rather than starting work.
That eliminates the waste of downstream services computing answers for requests the caller has abandoned, and it makes retries budget-aware.
What must accompany timeouts
Timeouts alone convert slowness into errors. Add bulkheads — separate connection pools per dependency, so one slow dependency exhausts only its own allocation — and circuit breakers, so a consistently failing dependency is skipped rather than repeatedly waited on.
What a strong answer adds
Auditing the estate for the defaults nobody set: connection acquisition timeouts, socket timeouts, DNS resolution timeouts, and — the one that causes indefinite hangs — a connection pool with no wait timeout, which turns a brief database slowdown into a permanently hung service.
Common weak answers
Halving the default without measuring. Adding retries, which makes an overload worse.