Engineering With Java

Engineering With Java

Spring Boot Interview - Adaptive Timeouts for Outbound Call

Adaptive Timeouts, Outbound Calls, Code Examples, Concept & Discussion and more ...

Suraj Mishra's avatar
Suraj Mishra
Feb 25, 2026
∙ Paid

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 )

So far we have covered 44+ real world based interview questions and will add up to 100 by end of this year.

Subscribe

Not convinced? Check out the details of the past work


Q2. How would you implement adaptive timeouts?

  1. Measure response time for each outbound call

  2. Maintain latency metrics per downstream service

  3. 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.

User's avatar

Continue reading this post for free, courtesy of Suraj Mishra.

Or purchase a paid subscription.
© 2026 Suraj Mishra · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture