Skip to content
SeeItFlow
Interactive guide · 4 chapters · ~14 min read

Load Balancer Interview & Revision

Interview prep for load balancers usually focuses on algorithm choice, health check design, and session-affinity trade-offs — this section condenses those into revision notes, a self-test quiz, and a cheat sheet.

Mangesh MandlikLast updated:
01 · Practice

Interview Questions

Use these prompts to practice the core explanations and trade-offs behind load balancing.

What is a load balancer and why do we need one?

It distributes requests across multiple backend servers to increase throughput and availability, and provides a single stable entry point for clients.

Explain the difference between Layer 4 and Layer 7 load balancing.

L4 routes using IP/TCP/UDP metadata such as IPs and ports, without parsing the application payload; L7 understands the application protocol (commonly HTTP/HTTPS or gRPC) and can route on host, path, headers, or cookies.

How does a load balancer detect a failed server?

Via periodic active health checks (e.g., GET /healthz) and/or passive monitoring of real request failures, using consecutive-failure/success thresholds to avoid flapping.

What are sticky sessions and when would you avoid them?

They pin a client to the same backend server so in-memory session state is preserved. Avoid them when possible in favor of a shared session store (Redis/DB), because affinity is a workaround that can create uneven load and a soft dependency on a specific backend.

How would you deploy a new version with zero downtime?

Blue/Green (instant cutover, instant rollback, double infrastructure cost) or Canary (gradual traffic ramp, smaller blast radius, slower rollout) — both rely on the load balancer to shift traffic.

How does global load balancing work across regions?

GeoDNS or anycast routes each user to their nearest healthy region; if a region's health checks fail, traffic automatically reroutes to the next-nearest healthy region.

What happens during auto scaling?

New instances register with the load balancer once they pass health checks; on scale-in, instances are drained (stop receiving new requests, finish in-flight ones) before termination.

Design a load balancer for a system handling 1M requests/sec.

Layer an L4/anycast tier for raw connection volume and DDoS absorption, feeding an L7 tier for content-aware routing; use least-connections or least-response-time algorithms, aggressive but well-tuned health checks, TLS termination at the edge, and shared session state to avoid sticky sessions limiting distribution. Illustrative sizing (assumptions, not measurements): if one L7 node sustains 50,000 requests/s and you plan for 60% peak utilisation, you need 1,000,000 / (50,000 × 0.6) ≈ 34 nodes, so 35 with one spare. At an assumed 10 KB average response that is 1,000,000 × 10 KB ≈ 80 Gbit/s of egress, and with an assumed 50 ms average latency about 50,000 requests are in flight at once (Little's law: 1,000,000 × 0.05 s).

02 · Quick reference

Revision Notes

The condensed version of the fundamentals, production, and trade-off discussions.

Key takeaways
  1. 01Load balancer = single entry point + traffic distribution + health monitoring, often plus TLS handling.
  2. 02L4 = connection-level metadata (fast, protocol-agnostic, no path/header/cookie routing). L7 = request-level visibility (content-aware, more CPU).
  3. 03Algorithms: Round Robin, Weighted Round Robin, Least Connections, IP Hash, Least Response Time.
  4. 04Health checks need both an unhealthy threshold and a healthy threshold to avoid flapping.
  5. 05Sticky sessions pin a client to a server — useful for stateful backends, but a shared session store is usually the more scalable design.
  6. 06TLS termination centralizes certificates and frees backend CPU; internal traffic may be plaintext unless you re-encrypt, while passthrough keeps end-to-end TLS but gives up most L7 routing.
  7. 07Auto scaling requires registration on boot and connection draining on scale-in.
  8. 08Blue/Green = instant cutover + instant rollback, double cost. Canary = gradual ramp, smaller blast radius.
  9. 09Global load balancing often uses GeoDNS (slower failover) or anycast (faster failover) to route to the nearest healthy region.
03 · Self-test

Quiz

Answer these from memory first; each question carries its short answer to check against.

Q1

Why can't a Layer 4 load balancer route based on a URL path? Answer: Because it only sees IP addresses, ports and connection state; the URL path lives inside the HTTP payload, which an L4 balancer does not parse (and which may be encrypted end-to-end under TLS passthrough).

Q2

What's the difference between an unhealthy threshold and a healthy threshold in a health check config? Answer: The unhealthy threshold is how many consecutive failed probes remove a server from rotation; the healthy threshold is how many consecutive passes bring it back. Both exist to prevent flapping.

Q3

Why does IP hash give you a lightweight form of session affinity, and what's its main downside? Answer: Hashing the client IP maps it to the same server every time without cookies. The downside is skew: many users behind one NAT or proxy share an IP and pile onto one server, and pool changes remap clients.

Q4

What is connection draining, and why does skipping it cause visible errors during a deploy? Answer: Draining stops sending new requests to an instance and waits for in-flight ones to finish before shutdown. Skipping it kills requests mid-flight, which clients see as errors.

Q5

Name one advantage and one disadvantage of Blue/Green deployments compared to Canary. Answer: Advantage: instant cutover and instant rollback. Disadvantage: it needs a full parallel environment (about double the infrastructure during the switch) and shifts all traffic at once, so a bad release reaches everyone, unlike a canary's small blast radius.

Q6

Why is anycast-based failover faster than GeoDNS-based failover? Answer: Anycast failover is a routing decision (a withdrawn BGP announcement moves traffic), so it avoids DNS caching delays, though it still depends on BGP convergence. GeoDNS failover waits for cached answers to expire.

04 · One page

Cheat Sheet

The whole module on one page.

textLoad Balancer at a glance
WHAT: single entry point that distributes requests across backend servers
WHY: throughput (horizontal scaling) + availability (no single point of failure)

LAYERS
  L4 — routes using IP+port metadata, no path/header/cookie visibility
  L7 — understands HTTP/gRPC, routes on path/header/cookie, more CPU

ALGORITHMS
  Round Robin            — fixed rotation
  Weighted Round Robin   — rotation weighted by server capacity
  Least Connections      — fewest active connections wins
  IP Hash                — same client IP -> same server
  Least Response Time    — fastest recent responder wins

HEALTH CHECKS
  active probe (e.g. GET /healthz) + passive failure observation
  unhealthy threshold (remove) / healthy threshold (rejoin)

SESSION AFFINITY
  sticky sessions (cookie or IP hash) = workaround for stateful backends
  shared session store is usually the preferred design

SSL / TLS
  termination at LB -> centralizes certs, frees backend CPU
  re-encryption -> LB decrypts, then opens a new TLS connection to backend
  passthrough -> end-to-end TLS, but most L7 routing features are unavailable

SCALING
  register on boot (after health check pass)
  drain connections before terminating on scale-in

DEPLOYMENTS
  Blue/Green — instant cutover + rollback, 2x infra cost
  Canary     — gradual ramp (5% -> 25% -> 50% -> 100%), small blast radius

GLOBAL
  GeoDNS  — DNS-based, slower failover (caching)
  Anycast — routing-based, failover bounded by BGP convergence