Spring Boot Interview - Adaptive Timeouts for Outbound Call
Adaptive Timeouts, Outbound Calls, Code Examples, Concept & Discussion and more ...
Scenario
You are building a Spring Boot microservice that calls multiple external services over HTTP (e.g., payment gateways, third-party APIs).
Currently, the service uses timeouts for these outbound calls. However, we’ve observed:
Some services are slow under load, but usually respond quickly.
Requests terminate too early or wait too long, wasting resources.
We want services to be resilient, avoid cascading failures, and adapt dynamically to the service’s response times.
Services uses fixed timeouts for outbound calls:
Fixed Timeout Using Declarative HTTP Client
Q1. What is the problem with fixed timeouts in modern applications?
Fixed timeouts assume that:
downstream latency is stable
traffic patterns are predictable
failures are consistent
In reality:
latency fluctuates under load
network delays vary
different services behave differently
Consequences:
premature failures during temporary slowdowns
blocked threads during downstream outages
cascading failures across microservices
📢 Get actionable Java/Spring Boot insights every week — from practical code tips to real-world use-case based interview questions.
Join 5500+ subscribers and level up your Spring & backend skills with hand-crafted content — no fluff.
First 100 paid subscribers will get the annual membership at $50/year ( 68 already converted to paid, 32 remaining )
Not convinced? Check out the details of the past work
Q2. How would you implement adaptive timeouts?
Measure response time for each outbound call
Maintain latency metrics per downstream service
Compute timeout dynamically based on recent observations
This converts static configuration into runtime behavior, allowing faster services to complete quickly while giving slow services slightly more time.





