Spring Cloud LoadBalancer DNS service discovery lacks a supported TTL refresh default
0 reputation · 13 Jun 2026, 15:37 UTC
0 reputation · 13 Jun 2026, 15:37 UTC
In current Spring Boot and Spring Cloud releases, Spring Cloud LoadBalancer can resolve service instances through DNS, but the framework does not define its own DNS cache TTL or negative caching policy. Instead, resolution is delegated to the JVM’s InetAddress implementation, meaning cache lifetime and refresh behavior are governed by the networkaddress.cache.ttl and networkaddress.cache.negative.ttl system properties or the OS resolver.
Because those settings apply process-wide, an application cannot tune DNS freshness for load-balanced calls without affecting every other outbound connection in the same JVM. It is uncertain whether a supported Spring-level configuration exists, or whether teams must accept JVM-wide DNS caching, supply a custom resolver bean, or rely on an external DNS resolver.
Additionally, the HTTP client stack influences how resolution failures surface: RestTemplate with HttpURLConnection and WebClient with Reactor Netty may behave differently when cached DNS entries become stale, so the active client stack and JVM DNS properties must be verified. Without a documented Spring default, the cache strategy remains an application-level design decision.
What is the supported way to control DNS cache TTL refresh for Spring Cloud LoadBalancer DNS service discovery without altering JVM-wide resolver settings? Does Spring Boot expose an auto-configuration hook to override the resolver or cache policy used by WebClient and RestClient? How should teams reconcile differing DNS caching behavior between RestTemplate and WebClient when stale records cause intermittent failures?
A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.