Load balancing, proxies and networking
44 questions in 10 subtopics.
Every request in a distributed system passes through load balancers, proxies and network protocols before it reaches application code, and many production incidents start there: uneven load after scaling, health checks that flap, retries at the gateway that duplicate orders, connections that silently die behind a NAT, or certificates and handshakes that overload an edge after a restart. This topic covers how layer 4 and layer 7 balancing differ, the main balancing algorithms, health checks and failover, sticky sessions, DNS and global traffic management, reverse proxies and API gateways, TLS termination and mutual TLS, HTTP/2, HTTP/3 and gRPC transport, long-lived connections with WebSockets and server-sent events, and service meshes. The questions move from how each mechanism works to debugging real symptoms and to the platform and ownership decisions senior engineers make.
L4 and L7 load balancing
A layer 4 balancer forwards TCP or UDP connections without reading them; a layer 7 balancer parses HTTP and decides per request. Understand what each can see and do, why connection-level balancing fails for long-lived HTTP/2 and gRPC connections, how client addresses are lost or preserved through proxies, and why large platforms put a layer 4 tier in front of layer 7 proxies.
Load balancers work at different layers. A layer 4 balancer forwards TCP or UDP connections without reading their content; a layer 7 balancer understands the application protocol, usually HTTP, and handles each request.
Explain what each kind can see and do, and which you would choose for a public REST API, a PostgreSQL connection pool endpoint and a game server using UDP.A gRPC service runs 6 pods behind a layer 4 cloud load balancer. After autoscaling to 10 pods during a peak, the 4 new pods receive almost no traffic while the original 6 sit at 90 percent CPU, and latency climbs.
Explain the imbalance and give the ways to fix it.A team replaced the layer 7 load balancer in front of its API with a layer 4 one to support a new TCP protocol. The next day the per-client rate limiter blocked most users, and logs show every request coming from a handful of internal IP addresses.
What happened to the client addresses, and how do you get them back?A public platform must handle 2 million HTTPS requests per second at peak with 400,000 concurrent client connections, route by host and path to about 150 services, and survive the loss of a zone or of individual balancer nodes.
Design the load-balancing tiers from the client to the services, and explain why each tier exists.Your company runs its own fleet of HAProxy and Envoy load balancers at the edge, operated by a team of four. A cloud provider's managed load balancers would remove this work but cost more per request and lack two features you rely on.
As the senior technical leader, how do you decide whether to keep the self-run fleet or move to managed load balancers?Load-balancing algorithms
Balancers choose backends with round robin, weighted variants, least connections or outstanding requests, random with two choices, or hashing on a key. Learn which fits uniform or uneven requests, why many independent balancers need randomness, how new instances get flooded without slow start, and how consistent hashing gives affinity while bounded loads protect against hot keys.
A load balancer must choose a backend for each request or connection. Common algorithms include round robin, weighted round robin, least connections, least outstanding requests, random with two choices, and hashing on a key.
Explain how each works and give a situation where each is the right choice.A Java client calls a list of service instances directly and needs a simple balancer that sends each request to a lightly loaded instance. Each instance object tracks its number of in-flight requests in an AtomicInteger.
A Spring Boot service behind a balancer using least outstanding requests is scaled out at peak. Each new pod is immediately flooded, its p99 jumps to several seconds, it fails readiness checks, is removed, recovers, and the cycle repeats.
Why does the algorithm hurt new pods, and how do you fix it?An API service runs 12 pods behind round robin. Most requests take 5 ms, but report requests take 2 to 4 seconds and arrive in bursts. During bursts, one or two pods reach 100 percent CPU and time out while others are idle.
Explain why round robin performs badly here and what you would change.A recommendation service keeps per-user model features in a local cache on each of 40 pods. To improve the hit ratio, the team wants to route requests for the same user to the same pod. A few very active users and bots generate thousands of requests per second each.
Design the routing, and explain how it handles pod changes and hot users.Health checks and failover
Health checks decide which backends receive traffic. Active probes test instances on a schedule, while passive outlier detection watches real responses. Know how intervals and thresholds set detection time, why checking shared dependencies can remove every instance at once, how gray failures and partial zone failures evade simple probes, and when failover should be automated or left to people.
A load balancer must stop sending traffic to broken backends. Active health checks probe each backend on a schedule; passive checks, also called outlier detection, watch real traffic for errors.
Explain both kinds, how interval and thresholds decide detection time, and what a health endpoint should check.An API's health endpoint checks the database. During a 2-minute database slowdown, every instance failed its health check, the load balancer marked all targets unhealthy, and users got errors for 9 minutes, long after the database recovered.
Explain how the health check turned a short slowdown into a long outage, and how to fix it.One of 15 instances of a service has a corrupted local cache and returns HTTP 500 for about 30 percent of requests. Its /health endpoint returns 200, so it stays in rotation, and the service's error rate has sat at 2 percent for six hours.
How do you get the balancer to remove this instance automatically, and what are the risks of doing so?A service runs in three zones behind a regional load balancer. A network fault in one zone causes 20 percent packet loss: health checks against that zone flap between healthy and unhealthy every minute, and users see intermittent timeouts for 40 minutes.
Design health checking and failover so a partially failing zone is removed quickly and cleanly, and is not brought back too early.Last year an automated database and traffic failover system triggered falsely three times, causing more downtime than the real incidents it handled. Some engineers want to remove automation and fail over manually; others want more automation.
As the senior technical leader, how do you decide which failovers are automated, and how do you make automation trustworthy?Sticky sessions
Sticky sessions send a client's requests to the same backend using a cookie or a hash of the client address, usually to find in-memory session data again. Understand how stickiness is implemented, why it causes uneven load after deploys and behind shared network addresses, why it gives affinity but never durability, and how key-based routing differs for stateful workloads.
Sticky sessions, or session affinity, make a load balancer send all requests from one client to the same backend, usually so that server-side session data held in memory is found again.
How do load balancers implement stickiness, and what happens to a sticky user when their backend is removed?A web app uses sticky sessions with a one-day cookie. After a rolling deploy, the three pods that came up first carry 70 percent of traffic while new pods sit nearly idle. Separately, one pod using IP-based affinity for an API gets traffic from 20,000 users behind one corporate network address.
Explain both imbalances and how you would fix them.A collaborative whiteboard keeps each board's live state in memory on one server, and all users of a board must reach that server. There are 30 servers and 200,000 active boards; servers are deployed daily and sometimes crash.
Design the routing and failover, and explain why cookie-based stickiness is not enough here.DNS and global traffic management
Global traffic management sends users to the right region using DNS answers based on location, latency, weights and health, or anycast addresses announced from many sites. Learn how TTLs and client caching slow DNS failover, why long-lived connections ignore DNS, how to size regions so failover does not overload survivors, and how to treat the DNS provider itself as a dependency.
Global traffic management sends users to one of several regions or sites. DNS-based approaches answer name lookups differently by location, latency, weight or health; anycast announces the same IP address from many places and lets network routing choose.
Explain how DNS-based global load balancing works, the role of TTL, and how anycast differs.During a regional outage the team changed DNS to remove the failed region; records had a 60-second TTL. Twenty minutes later about 15 percent of traffic was still arriving at the dead region's addresses, mostly from mobile apps and partner backends.
Why does traffic keep going to the old addresses, and how would you make failover faster?A service runs in three regions sized for 40, 35 and 25 percent of global traffic. Product requires that users reach the nearest healthy region and that the loss of any one region causes no outage. Last year a failover overloaded the surviving region.
Design global traffic management, including capacity, health and how traffic moves during failover.An outage at your single managed DNS provider made your domains unresolvable for three hours, although all your services were healthy. The board asks whether this can happen again and what it costs to prevent.
As the senior technical leader, how do you decide whether to use multiple DNS providers, and what else do you change?Reverse proxies and API gateways
A reverse proxy receives requests on behalf of servers, terminating TLS, buffering slow clients and routing to backends; an API gateway adds authentication, rate limits and per-API policies. Understand which retries and timeouts are safe at this layer, how proxies protect thread-per-request servers, and how to keep a shared gateway from becoming a single blast radius or a delivery bottleneck.
A reverse proxy sits in front of servers and receives client requests on their behalf; a forward proxy sits in front of clients and sends their requests out. An API gateway is a reverse proxy with API features such as authentication, rate limits and routing per API.
What does a reverse proxy such as NGINX or Envoy do for the Java services behind it, and what does an API gateway add on top?At peak, POST /orders takes about 3 seconds while the gateway's upstream timeout is 2.5 seconds, and the gateway retries timed-out requests on another instance. Finance reports about 400 duplicate orders that day.
Explain how the duplicates were created, and how gateway retries and timeouts should be configured.A Spring Boot service on Tomcat with 200 threads serves mobile clients that upload photos over slow networks. During evenings the service stops responding while CPU is at 15 percent; thread dumps show most threads blocked reading request bodies.
What is happening, and how can a reverse proxy in front of the service fix it?One shared API gateway cluster fronts 200 services. A team deployed a custom plugin with a regular expression that uses heavy CPU on some request paths, and every API in the company returned errors for 35 minutes.
How would you change the gateway's design and change process so one team's change cannot take everything down?A central platform team owns the API gateway. Every route, rate limit and authentication change goes through its ticket queue, which now takes three weeks, and some teams have started deploying their own gateways.
As the senior technical leader, how do you organise gateway ownership so teams move quickly while the edge stays safe?TLS termination and mTLS
TLS can be terminated at the balancer, passed through to the backend, or terminated and re-encrypted, each with different visibility and certificate handling. Mutual TLS adds client certificates so both sides prove identity. Know how the handshake works and what it costs, why Java clients sometimes send no client certificate, how resumption saves CPU at scale, and how compliance shapes where decryption may happen.
TLS encrypts traffic between client and server. A load balancer or proxy can terminate TLS (decrypt it), pass it through untouched to the backend, or terminate and re-encrypt to the backend. Mutual TLS also authenticates the client with a certificate.
Compare termination, passthrough and re-encryption, and explain what mTLS adds and what the handshake costs.A Spring Boot service now requires client certificates (server.ssl.client-auth=need). One calling Java service fails every call; the server logs javax.net.ssl.SSLHandshakeException: Empty client certificate chain, although the caller has a keystore configured.
An edge proxy fleet holding 300,000 mobile client connections was restarted for an urgent patch. All clients reconnected within seconds, proxy CPU reached 100 percent on TLS handshakes, and the login service behind it was overwhelmed for 15 minutes.
Why was reconnection so costly, and what would you change in the proxies, the certificates and the clients?Your payment card environment is subject to strict compliance. A proposal moves TLS termination from your own load balancers to a cloud provider's global edge to gain DDoS protection and lower latency, which means the provider's edge sees decrypted card data.
As the senior technical leader, how do you decide where TLS is terminated for regulated traffic?HTTP/2, HTTP/3 and gRPC transport
HTTP/2 multiplexes streams over one TCP connection, HTTP/3 moves to QUIC over UDP to avoid transport head-of-line blocking, and gRPC rides on HTTP/2. Understand stream limits and flow control windows, keepalive pings and idle timeouts on network devices, message size limits, and how to roll out HTTP/3 with fallbacks and measurements on real networks.
HTTP/1.1 sends one request at a time per connection. HTTP/2 multiplexes many streams over one TCP connection, and HTTP/3 runs HTTP over QUIC, a transport built on UDP with TLS 1.3 inside. gRPC uses HTTP/2 as its transport.
Explain what problem each version solves, where head-of-line blocking remains, and what that means for gRPC.A Java service calls a gRPC API in another network through a cloud NAT gateway that silently drops idle flows after 350 seconds. Each morning the first calls hang until their deadline. A client keepalive every 10 seconds was added, and now the server sends GOAWAY with too_many_pings.
Explain both problems and configure keepalive correctly on client and server.A batch job sends requests to a gRPC service over one ManagedChannel across a 60 ms link. Throughput stops at about 100 concurrent calls while server CPU is 30 percent, client latency rises, and some 5 MB responses fail with RESOURCE_EXHAUSTED.
A mobile-first product has many users on lossy cellular networks in several countries. The edge team proposes enabling HTTP/3 on the CDN and edge proxies, and the product team expects faster page and API loads.
How would you roll out HTTP/3, measure whether it helps, and handle the networks where it fails?WebSockets, SSE and long polling
Long polling, server-sent events and WebSockets keep connections open so servers can push updates. Learn what each looks like on the wire, which proxy settings they need, why idle timeouts and browser connection limits cause mysterious drops and hangs, and how to rebalance and deploy a fleet that holds hundreds of thousands of long-lived connections.
Browsers get server updates without reloading in three main ways: long polling (a request held open until data arrives), server-sent events (a one-way stream over HTTP) and WebSockets (a two-way connection upgraded from HTTP).
Explain what each looks like on the wire and what proxies and load balancers must allow for each.A dashboard opens one server-sent events stream per browser tab. Users with more than five tabs open report that new tabs hang while loading and buttons stop responding. The site is served over HTTP/1.1.
What is causing the hang, and how do you fix it?A chat feature uses WebSockets through NGINX and a cloud load balancer to Spring Boot. In development it works, but in production connections drop exactly every 60 seconds when nobody types, and some clients never connect, receiving HTTP 400 or 426 on the upgrade.
Explain both problems and the configuration needed at each hop.A notification service holds 400,000 WebSocket connections on 20 nodes. Before an event, 10 more nodes were added, but they stayed nearly empty while the original nodes ran short of memory, and rolling deploys take two hours because each node waits for its connections to end.
Why does scaling out not help, and how would you balance and deploy long-lived connections?Service mesh
A service mesh puts proxies, managed by a control plane, between services to provide mutual TLS, routing, retries and telemetry without code changes. Understand sidecar and node-level modes, startup and shutdown ordering problems, how mesh retries combine with application retries, how configuration size and push latency grow with the cluster, and how to weigh a mesh against application-level alternatives.
A service mesh moves service-to-service networking out of application code into the platform. A data plane of proxies handles traffic; a control plane configures them. Istio and Linkerd are common meshes on Kubernetes.
Explain how a mesh works, what it gives a Spring Boot service without code changes, and what it costs.After sidecar injection was enabled for a namespace, some Spring Boot pods crash at startup with connection refused when fetching configuration, and Kubernetes Jobs in the namespace never complete because their pods keep running after the work is done.
Explain both problems and how to fix them.During a short slowdown of an inventory service, its traffic rose to about 9 times normal and it collapsed. Callers use Resilience4j with 3 attempts, and the mesh also applies a retry policy to the same calls.
Explain how the layers multiplied the load, and how you would set retries and timeouts between application and mesh.A cluster runs 3,000 pods with Istio sidecars across 400 services. Each sidecar uses about 300 MB of memory, configuration changes take 40 seconds to reach all proxies, and during deploys callers see bursts of 503 errors with the Envoy flags UF and UH.
Explain the causes and how you would bring the mesh back under control.Security requires mutual TLS between all 150 services by next year. One group proposes a sidecar service mesh, another wants Spring Boot SSL bundles with an internal certificate authority, and a third proposes the mesh's sidecar-free ambient mode.
As the senior technical leader, how do you decide, and how do you plan the rollout?