Load Balancing is just one of the many networking services provided by the vCloud Networking and Security Edge Gateway which is a part of the VMware vCloud Networking and Security solution. By default, when the load balancing service is enabled, Layer-7 (L7 proxy) load balancing is automatically used which uses both SNAT (Source Network Address Translation) and DNAT (Destination Network Address Translation). However, an additional load balancing mode Layer-4 (L4) can be enabled using the vCloud Networking and Security APIs. Layer-4 mode only uses DNAT and preserves the original client IP Address of the request. In addition to the above differences, there are also performance differences between L7 and L4 load balancing and you can find more details in the recently published KB article (KB2042799).
Note: Both L7 and L4 load balancing methods are officially supported, but only L4 load balancing can be enabled when using the vCloud Networking and Security Edge APIs. This specific API call is also documented in the vCloud Networking and Security API Programming Guide on Page 139.
In this article I will demonstrate how to use the vCloud Networking and Security APIs to enable L4 load balancing. If you have not worked with the vCloud Networking and Security APIs, take a look at this blog article, which goes over a quick introduction and provides several quick walk through tutorials.
In the example below, I will be using cURL to interact with the vCloud Networking and Security API, which is exposed as a REST API. I will assume you already have a load balancer configured using either the vCloud Networking and Security UI or REST API.
Step 1 – We first need to identify the specific vCloud Networking and Security Edge gateway. Run the following command to list all Edge Gateways:
curl -i -k -H “content-type: application/xml” -H “Authorization: Basic YWRtaW46ZGVmYXVsdA==” -X GET https://10.20.181.174/api/3.0/edges
The edge gateway name will be identified in the ObjectId tag and it should have a name similar to: edge-15
Step 2 – Next we will need to retrieve the edge gateway configuration. Run the following command and substitute the Edge Gateway name from the previous step into the URL below:
curl -i -k -H “content-type: application/xml” -H “Authorization: Basic YWRtaW46ZGVmYXVsdA==” -X GET https://10.20.181.174/api/3.0/edges/edge-15/loadbalancer/config
The following parameter <accelerationEnabled>false</accelerationEnabled> determines whether or not L4 load balancing is enabled. By default this is set to false and L7 is used. To enable L4 load balancing, we just need to update the Edge Gateway configuration and specify true for this parameter.
Step 4 – To enable L4 load balancing for the Edge Gateway, we will use the POST operation and specify either “true” or “false” for the enable parameter in the URL below. Run the following command to update the Edge Gateway configuration:
curl -i -k -H “content-type: application/xml” -H “Authorization: Basic YWRtaW46ZGVmYXVsdA==” -X ‘POST https://10.20.181.174/api/3.0/edges/edge-15/loadbalancer/acceleration?enable=true’
Step 5 – To confirm that we have successfully enabled L4 load balancing, we can perform another GET operation on the Edge Gateway configuration and we should see that the <accelerationEnabled> parameter should state true now. A restart of the load balancer is not required for this change to go into effect
Get notification of new blog postings and more by following lamw on Twitter: @lamw