unemployed.dev☕ Support
system-design/load-balancers
Topic 03Building Blocks

Load Balancers

Distribute traffic so no single server becomes the bottleneck.

A load balancer sits between clients and your server fleet. It routes incoming requests, detects unhealthy servers, and enables horizontal scaling. Without one, you have a single point of failure.

What a load balancer does

Core responsibilities at the network layer.

  • Distributes requests across multiple servers
  • Health checks servers — stops routing to failing nodes
  • Enables rolling deploys without downtime
  • Provides a single public IP for a fleet of private servers
  • Can terminate SSL, handle rate limiting, or add headers

Routing algorithms

How requests get assigned to servers.

  • Round robin — each server in turn. Simple, works for stateless services.
  • Least connections — route to the server with fewest active connections.
  • IP hash — same client IP always hits the same server. Useful for session stickiness.
  • Weighted round robin — newer or more powerful servers get more requests.

L4 vs L7 load balancing

The layer determines what decisions the balancer can make.

  • L4 (transport) — routes based on IP + TCP port. Fast, but no content awareness.
  • L7 (application) — routes based on HTTP headers, URL, or body. More flexible, slightly more overhead.
  • Use L7 when you need path-based routing, A/B testing, or content inspection.

Interview tips

  • Mention load balancers early in any high-traffic design
  • Specify stateless vs stateful — it determines your routing strategy
  • Always address: what if the load balancer itself fails?
  • In cloud designs, say 'AWS ALB' or 'NGINX' to show real-world familiarity

Follow-up questions to expect

  • ?What happens if the load balancer goes down?
  • ?How do you handle session state when requests can hit any server?
  • ?When would you use a L4 vs L7 load balancer?
TLDR
  • Load balancers prevent any one server from being a bottleneck
  • Round robin for stateless; IP hash for session-sticky services
  • L7 lets you route by URL path — useful for microservices
  • Health checks are what actually make LBs reliable
  • LBs themselves can become a SPOF — use redundant pairs