A load balancer distributes incoming traffic across multiple backend servers to prevent any single server from becoming overwhelmed. Layer 4 (TCP) load balancers route by IP/port. Layer 7 (HTTP) load balancers can route by URL path, headers, or cookies. Health checks remove failed backends automatically.
Load balancers sit between clients and a pool of backend servers, distributing requests to maintain availability and performance. Layer 4 load balancers (AWS NLB, HAProxy TCP mode) operate on TCP connections – fast, transparent, but cannot inspect application content. Layer 7 load balancers (AWS ALB, Nginx, HAProxy HTTP mode, Envoy) understand HTTP and can route based on URL paths, headers, cookies, and request content. Algorithms include: round-robin (equal distribution), least-connections (send to the least busy), weighted (manual capacity ratios), and consistent hashing (session affinity by key). Health checks probe backends periodically (HTTP GET /health, TCP connect, or custom script) and remove unresponsive servers from the pool within seconds. Without load balancers, a single server failure causes complete outage. With load balancers, failed servers are automatically drained and traffic reroutes to healthy instances.
Reverse Proxy
A reverse proxy sits in front of backend servers, accepting client connections and forwarding requests to appropriate backends. Unlike a forward proxy (client-side), a reverse proxy is server-side and invisible to clients. Provides TLS termination, caching, compression, rate limiting, and security filtering. Nginx, Caddy, and Envoy are common reverse proxies.
Health Check
A health check is a periodic probe that determines whether a service instance is able to handle traffic. Load balancers, orchestrators (Kubernetes), and service meshes use health checks to route traffic only to healthy instances. Types: liveness (is the process alive?), readiness (can it serve requests?), and startup (has it finished initializing?).
High Availability (HA)
High availability is a system design that minimizes downtime by eliminating single points of failure. Measured in 'nines' – 99.9% (8.7h downtime/year), 99.99% (52min/year), 99.999% (5min/year). Requires: redundant components, automatic failover, health monitoring, and tested recovery procedures.