Using Weighted Round Robin Load Balancing With HAProxy

HAProxy can also be configured to use the weighted round-robin algorithm to distribute traffic. This algorithm selects servers in turns, according to their weights, and distributes the server load without implementing certain other factors such as server response time. With weighted round-robin, you can balance traffic proportionally between servers based on processing power and resources available to a server.

  1. Configure the server for standard round robin load balancing.
  2. Edit the HAProxy configuration to append weight values to each server in the configuration.

    For example, to distribute twice the amount of traffic to websrv1, change the configuration to include different weight ratios, as follows:

    server websrv1 192.168.1.71:80 weight 2 maxconn 512 check
    server websrv2 192.168.1.72:80 weight 1 maxconn 512 check
  3. Reload the HAProxy systemd service.
    sudo systemctl reload haproxy