Scrivio Interview library
ScenarioIntermediate6 min read · updated 12 November 2026

Your services run on Kubernetes. Would you use Spring Cloud LoadBalancer with discovery, rely on Kubernetes Services, or use a service mesh? What trade-offs drive the choice?

A Kubernetes Service balances at layer 4, per connection, so with long-lived pooled HTTP/1.1 connections or a single multiplexed HTTP/2 connection, a few clients can stick to a few pods and load becomes uneven. Client-side balancing with Spring Cloud LoadBalancer spreads requests per call and can use health or zone information, but every language needs its own library. A service mesh moves balancing, retries and mTLS into sidecars or the platform at the cost of operating it. I would choose by whether load is actually uneven today, how polyglot the system is and who will run the platform, and make sure retries are not configured in both the client library and the mesh.

Why this question is asked

Teams moving Spring Cloud services onto Kubernetes often keep Eureka and client-side balancing out of habit, or drop it and later wonder why one pod runs hot while others idle. Others adopt a mesh because it is fashionable, then struggle to operate it. Interviewers ask this scenario to see whether we can connect a networking detail, how Kubernetes balances traffic, to an architectural choice with real operational costs. In this answer, we will recap how a Kubernetes Service balances, see when that causes uneven load, compare client-side balancing and a mesh, and then decide, including the trap of duplicated retries.

1How a Kubernetes Service Balances Traffic

A Kubernetes Service gives a set of pods one stable virtual IP and DNS name, such as inventory.shop.svc. When a client opens a TCP connection to that IP, kube-proxy (using iptables or IPVS rules on each node) or the cluster's network plugin picks one pod for that connection. This is layer 4 balancing: it works on connections, not on HTTP requests. Every request sent over that connection goes to the same pod for as long as the connection lives.

For short connections that is fine. The trouble comes from connection reuse, which every serious HTTP client does for performance.

2When Per-Connection Balancing Becomes Uneven

A Spring service with a pool of HTTP/1.1 keep-alive connections opens a handful of connections and reuses them for thousands of requests. Each connection was assigned to a pod when it opened. If the caller opened its 10 connections when inventory had 3 pods, and inventory then scales to 6, the new pods get nothing from this caller until connections are closed and reopened. HTTP/2 makes it worse, because one connection multiplexes all requests, so a caller may send everything to a single pod.

The symptom is visible in metrics: CPU or request rate per pod varies widely, new pods stay idle after scaling, and latency is driven by the hottest pod. If those symptoms are absent, the plain Service is working well enough. A cheap mitigation is to limit connection lifetime in the client pool, for example to a few minutes, so connections are periodically reopened and redistributed.

3Client-Side Balancing With Spring Cloud LoadBalancer

With Spring Cloud Kubernetes, the DiscoveryClient reads the pod endpoints behind a Service from the Kubernetes API, and Spring Cloud LoadBalancer chooses a pod for each request. Load spreads per request, not per connection, new pods receive traffic as soon as they appear in the endpoints, and the balancer can prefer pods in the same zone or skip unhealthy ones. The costs are that the application needs permission to read endpoints from the Kubernetes API, the instance list can lag behind reality by a cache interval, and only Java services benefit: a Go or Python service needs its own equivalent.

Java
# Spring Cloud Kubernetes discovery + LoadBalancer
spring.cloud.kubernetes.discovery.enabled=true
spring.cloud.loadbalancer.configurations=zone-preference # check names for your version
@Bean @LoadBalanced
RestClient.Builder lb() { return RestClient.builder(); }
// calls to http://inventory now pick a pod per request from the Service's endpoints

4A Service Mesh

A service mesh such as Istio or Linkerd puts a proxy next to every pod (a sidecar), or in newer designs on each node, and routes all traffic through it. The proxy balances at layer 7, per HTTP request, for every language. It also adds mutual TLS between services, retries, timeouts, traffic shifting for canary releases and uniform metrics, without application changes.

The cost is operational. Someone has to install, upgrade and debug the mesh, sidecars add memory and a small latency per hop, and a mesh misconfiguration can break every service at once. A mesh pays off when there are many services in several languages and a platform team with the skills and time to run it.

Three ways to balance on Kubernetes
OptionBalancesGainsCosts
Kubernetes Serviceper connection (L4)nothing extra to rununeven with pooled or HTTP/2 connections
Spring Cloud LoadBalancerper request, in the clientzone and health aware, no infraJava only, API access, cache lag
Service meshper request, in the proxyany language, mTLS, traffic shiftinga platform to run, extra hop

5Making the Choice

Three questions decide it. Is load actually uneven today? If per-pod metrics look even, the plain Service plus a connection lifetime limit is the simplest answer, with nothing new to operate. Is the system polyglot? If it is mostly Java and Spring, client-side balancing solves the problem cheaply; if it has five languages, a mesh gives one solution for all. Who operates the platform? A mesh without a team that understands it is a risk, not a feature.

Whatever we choose, we must avoid duplicating behaviour. If the mesh retries failed requests and the Spring client also retries, the attempts multiply, 3 x 3 = 9 per call, which is a retry storm waiting to happen. The same applies to timeouts, which must nest. When a mesh arrives, we decide which layer owns retries and switch them off in the other.

Step throughChoosing a balancing approach
  1. Is load uneven across pods today?
    YesNext questionNoKeep Service, cap connection lifetime
  2. Many languages, or mTLS needed everywhere?
    YesNext questionNoSpring Cloud LoadBalancer
  3. Team able to run a mesh?
    YesService meshNoClient-side now, mesh later
  4. Retries owned by one layer only

4 steps in order. Play them, or step through them one at a time.

6Follow-up questions

Does a headless Service help?

A headless Service, one without a cluster IP, makes DNS return the pod IPs directly. A client can then spread connections across pods itself, but most HTTP clients resolve DNS once per connection and cache it, so it does not give per-request balancing without client support. It is useful mainly together with a client-side balancer.

Why is HTTP/2 especially affected?

Because HTTP/2 sends all requests over one long-lived connection, so a layer 4 balancer that picks a pod per connection sends that client's entire traffic to one pod. gRPC, which uses HTTP/2, is the classic case where teams discover the need for per-request balancing.

Can we combine client-side balancing and a mesh?

We can, but there is little reason to. If the mesh balances per request, the client should simply call the Service name and let the mesh do it; client-side balancing on top just adds a second, possibly conflicting, decision.

7Conclusion

In this answer, we saw that a Kubernetes Service balances per connection, which becomes uneven when HTTP clients reuse pooled or HTTP/2 connections. Spring Cloud LoadBalancer with Kubernetes discovery balances per request inside Java clients, while a service mesh balances per request for any language and adds mTLS and traffic control at the cost of running it. We choose by measured unevenness, language mix and operating capacity, and we make sure retries and timeouts are owned by one layer, not duplicated in both the client and the mesh.

What to say in the interviewAbout 80 seconds aloud

Open with

The key fact is that a Kubernetes Service balances at layer 4, per connection. Our Spring clients pool keep-alive connections, and HTTP/2 multiplexes everything over one connection, so a caller can stick to a few pods, and new pods after scaling get nothing until connections are reopened.

Then, if they want more

So I would first check whether load is actually uneven, by looking at requests and CPU per pod. If it is even, the plain Service is the simplest answer, maybe with a maximum connection lifetime so connections get redistributed.

If it is uneven and we are mostly Java, Spring Cloud Kubernetes discovery with Spring Cloud LoadBalancer gives per-request balancing, zone preference and health awareness with no extra infrastructure, but it only helps Java services and needs access to the Kubernetes API.

If we are polyglot, or need mTLS and traffic shifting everywhere, a mesh like Istio or Linkerd does per-request balancing for every language, but someone has to operate it, and it adds a proxy hop. I would only choose the mesh if there is a platform team that can run it.

And whichever we pick, I would make one layer own retries and timeouts, because retries in both the Spring client and the mesh multiply.

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.
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 "Your services run on Kubernetes. Would you use Spring Cloud LoadBalancer with discovery...": https://scrivio-interview-library.netlify.app/spring-boot/http-clients/07289079e0/