contentintech

Load Balancing Cheatsheet

Quick reference for L4/L7 balancing, algorithms, health checks, sticky sessions, GSLB, and HA topologies.

L4 vs L7AlgorithmsHealth ChecksGSLB
NotesCheatsheet

L4 vs L7

L4 (transport)L7 (application)
SeesIP + portURL, headers, cookies
Routes byconnection / 5-tuplepath, host, header
Speedfastestparses payload
FeaturesminimalTLS term, WAF, rewrites
AWSNLBALB

L4 = throughput / non-HTTP. L7 = content routing, TLS, per-request logic (most web).

Algorithms

AlgorithmBest for
Round robinUniform, short requests
Weighted RRUnequal server capacities
Least connectionsLong-lived / variable requests
Least response timeAdapt to slow nodes
IP hashStickiness, no shared state
Consistent hashCache / shard affinity

Health Checks & Stickiness

CheckVerifies
PassiveEjects after N live-traffic failures
Active TCPPort accepts a connection
Active HTTPGET /healthz -> 200 in time
Sticky sessions: cookie-based or IP-hash
  -> needed only if state is in server RAM
  -> PREFER stateless (Redis/JWT); sticky breaks autoscale
liveness vs readiness: don't cascade-eject on shared dep blip

TLS & GSLB

TLS termination: client--TLS-->[LB]--HTTP-->backend (offload, central certs)
TLS passthrough: LB forwards encrypted (end-to-end, no L7 inspect)
Re-encryption:   terminate then new TLS to backend (both)
GSLBRouting
DNS-basedRegion IP by geo; TTL caching delays failover
AnycastOne IP, BGP to nearest PoP; fast failover
GeoDNS + latencyRoute to lowest-latency datacenter

HA & Tools

HA topologyBehavior
Active-passiveStandby claims VIP on failure (idle capacity)
Active-activeAll LBs serve; full capacity
VIP + keepalived (VRRP): MASTER holds VIP, BACKUP heartbeats,
  takes over via gratuitous ARP in ~seconds on failure
ToolStrength
HAProxyHigh-perf L4/L7
NginxReverse proxy + LB + TLS
EnvoyCloud-native L7, service mesh
AWS ELBALB L7 / NLB L4, managed

Reverse proxy = front door for backends (caching, TLS, routing), even for one server. LB = specifically spreads across many. Nginx/Envoy do both.

Section navigation