Load Balancing Documentation
Load balancing spreads traffic across multiple application instances.
Round Robin
Requests are sent to each backend in order. This is simple and works well when servers are similar.
Request 1 -> app1 Request 2 -> app2 Request 3 -> app3 Request 4 -> app1
Least Connections
New requests go to the backend with the fewest active connections. This helps when some requests take longer than others.
Health Checks and Failover
A production load balancer should stop sending traffic to unhealthy backends and resume when they recover.
Sticky Sessions
Sticky sessions keep one client connected to the same backend. This is useful for stateful applications but less ideal than storing session state externally.
Nginx Example
upstream website_pool {
server 127.0.0.1:8081;
server 127.0.0.1:8082;
server 127.0.0.1:8083;
}
location / {
proxy_pass http://website_pool;
}Kubernetes Scaling
kubectl scale deployment website -n cloud-platform --replicas=5 Ingress -> Service -> Pod1/Pod2/Pod3/Pod4/Pod5