Balancing modes and algorithms
Balancing modes
VMware NSX® Edge™ (Edge router) offers support for two modes of balancer deployment: proxy mode (one-arm) and transparent mode (inline).
Proxy mode (one-arm)
When sending a request to one of the backends in proxy mode, Edge uses its IP address as the source address — the balancer performs both Source and Destination NAT functions. The backend sees all traffic as sent from the balancer and responds directly to it. In this scheme, the balancer must be on the same network segment as the backend servers.
The user sends a request to the VIP address (balancer address) that is configured on the Edge. Edge selects one of the backends and performs Destination NAT, replacing the VIP address with the address of the selected backend. Edge performs Source NAT, replacing the address of the requesting user with its own, and the packet is sent to the selected backend.
The backend does not respond directly to the user, but to Edge, because the user's original address has been changed to the address of the balancer. Edge passes the server response to the user.
Transparent mode (inline)
In transparent mode, the load balancer has interfaces on the internal and external network, but the internal network is not directly accessible from the external network. The built-in load balancer acts as a NAT gateway for virtual machines on the internal network.
The user sends a request to the VIP address (balancer address) that is configured on the Edge. The Edge selects one of the backends and performs Destination NAT, replacing the VIP address with the address of the selected backend and the packet is sent to the selected backend.
The backend receives the request with the user's original address (Source NAT was not performed) and responds to it directly. The traffic is again received by the load balancer, since in an inline scheme it usually acts as the default gateway for the server farm. Edge performs Source NAT to send traffic to the user using its VIP as the Source IP address.
Balancing algorithms
- IP Hash — The server is selected based on the results of the hash function for the Source and Destination IP of each packet;
- Least Connections — incoming connections are balanced according to the number of connections already available on a particular server. New connections will be directed to the server with the least number of connections;
- Round Robin — new connections are sent to each server in turn according to the specified server weight;
- URI — the left part of the URI (up to the question mark) is hashed and divided by the total weight of the servers in the pool. The result indicates which server receives the request. The request is directed to the same server as long as all servers remain available;
- HTTP Header — balancing based on HTTP header, which can be specified as a parameter. If the header is missing or does not have a value, the Round Robin algorithm is applied;
- URL — in each HTTP GET request, the URL parameter specified as an argument is searched. If the parameter is followed by an equal sign and a value, the value is hashed and divided by the total weight of the running servers. The result indicates which server receives the request. This process is used to keep track of user IDs in requests. The User ID is sent to the same server as long as all servers remain available.