Nginx load balancing distributes traffic across multiple backend servers — providing horizontal scaling and automatic failover.
Configuration
upstream backend {
server web1.yourdomain.com:8080 weight=3;
server web2.yourdomain.com:8080 weight=2;
server web3.yourdomain.com:8080 backup;
}
server {
listen 80;
location / { proxy_pass http://backend; }
}
Load Balancing Methods
# Least connections
upstream backend { least_conn; server web1; server web2; }
# IP hash (sticky sessions)
upstream backend { ip_hash; server web1; server web2; }
Health Checks
server web1 max_fails=3 fail_timeout=30s;
Conclusion
Nginx load balancing enables horizontal scaling. Our team designs load-balanced server architectures for high-traffic applications.
Comments