100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

Load Balancing Strategies Cheat Sheet

Load Balancing Strategies Cheat Sheet

Covers core load balancing algorithms, Layer 4 vs Layer 7 balancing, health checks, and configuration examples using NGINX and AWS ELB.

2 PagesIntermediateJan 28, 2026

Load Balancing Algorithms

Common algorithms used to distribute traffic across backend servers.

  • Round Robin- Requests distributed sequentially across all servers in order
  • Weighted Round Robin- Servers with higher weight receive proportionally more requests
  • Least Connections- Routes to the server with the fewest active connections
  • Weighted Least Connections- Combines connection count with a server capacity weight
  • IP Hash- Hashes client IP to consistently route the same client to the same server
  • Least Response Time- Routes based on lowest latency plus fewest active connections
  • Random- Picks a server at random, often combined with 'power of two choices'

Layer 4 vs Layer 7

Key differences between transport-layer and application-layer load balancing.

  • Layer 4 (Transport)- Routes based on IP/port using TCP/UDP, no payload inspection, very fast
  • Layer 7 (Application)- Routes based on HTTP headers, URL path, cookies; enables content-based routing
  • AWS NLB- Layer 4 load balancer, handles millions of requests/sec with static IPs
  • AWS ALB- Layer 7 load balancer, supports path/host-based routing and WebSockets
  • SSL Termination- L7 LBs can decrypt TLS at the balancer, offloading CPU work from backends

NGINX Load Balancer Config

Basic upstream block for round-robin and weighted balancing.

nginx
upstream backend {    least_conn;                 # use least connections algorithm    server 10.0.0.1:8080 weight=3;    server 10.0.0.2:8080 weight=1;    server 10.0.0.3:8080 backup;  # only used if others are down}server {    listen 80;    location / {        proxy_pass http://backend;        proxy_set_header Host $host;        proxy_set_header X-Real-IP $remote_addr;    }}

Health Check Configuration

Defining active health checks so unhealthy targets are removed automatically.

bash
# AWS CLI: configure ALB target group health checkaws elbv2 modify-target-group \  --target-group-arn arn:aws:elasticloadbalancing:...:targetgroup/my-tg \  --health-check-protocol HTTP \  --health-check-path /healthz \  --health-check-interval-seconds 15 \  --healthy-threshold-count 2 \  --unhealthy-threshold-count 3
Pro Tip

Set your health check interval and timeout tighter than your deployment rollout speed, otherwise the LB will keep sending traffic to instances mid-restart during a rolling deploy.

Was this cheat sheet helpful?

Explore Topics

#LoadBalancingStrategies#LoadBalancingStrategiesCheatSheet#CloudComputing#Intermediate#LoadBalancingAlgorithms#Layer4VsLayer7#NGINX#Load#Algorithms#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech

Professional Web Designing Services

  • Responsive Websites
  • E-commerce Solutions
  • SEO Friendly Design
  • Fast & Secure
  • Support & Maintenance
Get a Free Quote

Share this Cheat Sheet