- Round Robin: Distributes requests evenly across all backend servers.
- Weighted Round Robin: Assigns traffic proportionally based on server weights.
- IP Hash: Routes each client IP to the same backend to maintain session persistence.



Load Balancing Algorithm Comparison
Environment Setup
We have three Ubuntu nodes in our test lab:- nginx: Nginx load balancer (192.230.202.10)
- node01 & node02: Apache backend servers
For security, restrict HTTP access so only the load balancer (192.230.202.10) can reach port 80 on your backends.
Configuring the Load Balancer
On the nginx node, create or edit your site configuration:1. Round Robin
Add anupstream block for your backend pool:
curl to see alternating responses:
2. Weighted Round Robin
Adjust theupstream block to assign server weights:
3. IP Hash
Enableip_hash for session stickiness by client IP:
With
ip_hash, each client IP always hits the same backend server. This is ideal for stateful applications.You can extend this setup with health checks, SSL termination, or alternative Nginx modules.