Quick revision
The short answer
I would treat network defaults as a platform product: one owned, documented set of values for DNS TTL, connection lifetime, idle keep-alive and timeouts, chosen to match how the infrastructure actually changes, and delivered through base images and shared client libraries rather than set per service. The reasoning behind each value is written down so teams do not change it blindly, the effective values are reported by every service, failover and IP changes are tested regularly in staging, and the defaults are reviewed whenever the infrastructure changes, for example when a service mesh is introduced.
What to remember
In this answer, we saw that JVM and library network defaults date from fixed servers and clash with cloud infrastructure whose addresses change. We chose DNS TTLs, pool lifetimes, keep-alive and timeouts that follow how the infrastructure behaves, delivered them through base images and a shared starter instead of per service, documented the reason for each value, reported effective values from every service, tested failovers and IP changes regularly in staging, and reviewed the defaults whenever the infrastructure changed, such as when adopting a service mesh.
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 treat network defaults as a platform product: one owned, documented set of values for DNS TTL, connection lifetime, idle keep-alive and timeouts, chosen to match how the infrastructure actually changes, and delivered through base images and shared client libraries rather than set per service. The reasoning behind each value is written down so teams do not change it blindly, the effective values are reported by every service, failover and IP changes are tested regularly in staging, and the defaults are reviewed whenever the infrastructure changes, for example when a service mesh is introduced.
Why this question is asked
Many of the defaults in the JVM and in popular libraries were chosen when servers had fixed addresses and lived for years. A DNS answer cached forever, a database connection kept open for hours, or an idle HTTP connection reused whenever it is needed were all reasonable then. In a cloud where load balancer addresses rotate, databases fail over by DNS and proxies close idle connections after a minute, the same defaults cause incidents. Interviewers ask this at the principal level to see whether we can fix a class of problems for a whole organisation instead of one service at a time. In this answer, we will see how old defaults clash with new infrastructure, choose values that follow the infrastructure, decide where the defaults live, document and test them, and set up a review cycle.
1A Quick Recap: Three Settings That Remember the Network
Three settings decide how quickly a Java client notices that the network has changed. The DNS cache TTL, networkaddress.cache.ttl, decides how long the JVM reuses a resolved address. The pool connection lifetime decides how long a database or HTTP connection, which is bound to one IP address, stays open before it is replaced. The idle keep-alive time decides how long an unused HTTP connection stays in the pool waiting to be reused.
Each one is a trade-off between efficiency and freshness. Long values save lookups and handshakes; short values follow changes. The problem in most organisations is not that a value is wrong, but that nobody chose it: each service inherits whatever its JDK, driver and HTTP library happen to default to, and those differ from library to library and version to version.
2How Old Defaults Clash With Cloud Infrastructure
Three examples show the clash. A JVM image configured with an infinite DNS TTL keeps talking to an old database primary after a DNS failover until the service restarts. A pool that never retires connections keeps old connections to a load balancer node that has been removed. And an HTTP client that keeps idle connections for longer than the load balancer's idle timeout, 60 seconds by default on a common cloud application load balancer, reuses a connection the load balancer has already closed, and the first request after a quiet period fails with a connection reset.
The third one is a good illustration of why the values must be chosen together with the infrastructure. The client's idle keep-alive must be shorter than every idle timeout on the path, so that the client closes idle connections before anything in the middle does. That is not something any single team can know; it is a fact about the platform.
3Choosing Values That Follow the Infrastructure
So the platform team picks values from the infrastructure's behaviour, writes them down with the reason, and makes them the default everywhere.
| Setting | Default | Reason |
|---|---|---|
| JVM DNS cache TTL | 30 s | Follows DNS failover and LB address changes within a minute |
| JVM negative DNS TTL | 5 s | New service names work soon after creation |
| DB pool max lifetime | 10 min | Old connections gone soon after failover |
| HTTP idle keep-alive | 50 s | Below the 60 s LB idle timeout, so no stale reuse |
| HTTP connection max lifetime | 5 min | Spreads load over new LB nodes |
| Connect / request timeout | 1 s / 5 s | Below callers' deadlines; override with a reason |
Notice that each value has a reason tied to a specific fact about the infrastructure. That reason is what makes the value governable: when the fact changes, everyone knows which values must be revisited.
4Where the Defaults Live
Defaults set per service drift within months, so they must live in layers that every service inherits. JVM-wide settings, such as DNS TTLs and security properties, belong in base images, typically as a java.security override passed through JAVA_TOOL_OPTIONS. Library-level settings, such as pool lifetimes, keep-alive and timeouts, belong in shared configuration: a company starter for Spring Boot that sets spring.datasource.hikari properties and HTTP client defaults, which services can override explicitly but get right by doing nothing.
- Service configurationexplicit, reviewed overrides only
- Company Spring Boot starterpool lifetime, keep-alive, timeouts, metrics
- Base image
java.securityoverride: DNS TTLs; JDK version - PlatformLB idle timeouts, DNS record TTLs, mesh settings
4 layers, from the top down. Step through them one at a time.
Each layer inherits from the one below and documents why it differs.
A service can still override a default, because a service knows things the platform does not, such as an unusually slow batch query. But the override is visible in its configuration, and code review asks for the reason.
5Documenting, Reporting and Testing
Documentation prevents the most common failure: a well-meaning engineer raises a timeout or a TTL to fix a symptom and quietly breaks failover. Each default has a short decision record explaining what it protects against, and the configuration file links to it in a comment. Reporting closes the loop: every service logs and exports its effective values at startup, so a dashboard shows which services deviate from the defaults, and why, before an incident does.
Testing proves the values work. In staging, we regularly trigger the events the defaults are meant to handle: a database failover, a load balancer replacing its nodes, a DNS change for a service, a proxy dropping idle connections. For each event we measure recovery time per service. A service that recovers in five seconds while another takes ten minutes points straight at a misconfiguration.
6Reviewing Defaults When Infrastructure Changes
The defaults are only correct for the infrastructure they were chosen for, so infrastructure changes must trigger a review. Introducing a service mesh is the classic example. With a sidecar proxy, the application connects to localhost, and the proxy handles DNS, load balancing, retries and connection lifetimes to the real destinations. The JVM DNS TTL then matters much less, while the proxy's own timeouts and retry policies matter much more, and duplicated retries in the application and the mesh can multiply load. Moving to a new load balancer type with a different idle timeout, changing database products, or adopting IPv6 are similar triggers. A simple rule, every infrastructure change proposal includes a check of the network defaults, keeps the two in step.
7Follow-up questions
Who should own these defaults?
A platform or developer experience team, with input from the teams running the infrastructure. They own the base images and the shared starter, so they are the ones who can change the defaults for everyone and who see the incident data across the fleet.
How do you stop teams from pinning old library versions with old defaults?
Track the version of the shared starter and base image per service, show it on a dashboard, and make upgrades cheap with automated dependency updates. Security patches give a natural reason to upgrade, and the new defaults arrive with them.
What if a team really needs a different value?
They override it in their configuration with a comment explaining why, and the reporting shows the override. Exceptions are fine; invisible exceptions are what cause incidents.
8Conclusion
In this answer, we saw that JVM and library network defaults date from fixed servers and clash with cloud infrastructure whose addresses change. We chose DNS TTLs, pool lifetimes, keep-alive and timeouts that follow how the infrastructure behaves, delivered them through base images and a shared starter instead of per service, documented the reason for each value, reported effective values from every service, tested failovers and IP changes regularly in staging, and reviewed the defaults whenever the infrastructure changed, such as when adopting a service mesh.
Open with
I would treat these settings as a platform product rather than something each team discovers in an incident. The JVM DNS TTL, pool connection lifetimes and idle keep-alive all decide how fast a client notices that the network changed, and their defaults come from a world of fixed servers.
Then, if they want more
So the platform team chooses one set of values from facts about our infrastructure: for example a DNS TTL of about 30 seconds so DNS failovers are followed within a minute, a pool maximum lifetime of around ten minutes so old connections disappear after a failover, and an HTTP idle keep-alive below the load balancer's idle timeout, so we never reuse a connection the load balancer has closed.
Those values are delivered centrally, the JVM-wide ones in base images through a java.security override and the library ones in a company Spring Boot starter, and services override them only explicitly with a reason. Each value has a short decision record so nobody changes it blindly, and every service reports its effective values so drift is visible.
We test failovers and IP changes in staging regularly and measure recovery time per service. And whenever the infrastructure changes, for example adopting a service mesh, which takes over DNS, retries and connection management, we review the defaults, because they are only right for the platform they were chosen for.
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
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
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 "Infrastructure moved from fixed servers to cloud endpoints whose IPs change frequently...": https://scrivio-interview-library.netlify.app/java/networking/c2a5b17b39/