Load Balancing
- Load balancing automatically distributes your inbound application traffics to the preconfigured backend VM instances, thereby providing highly concurrent and highly reliable access services.
- In your practice, you can adjust the VM instances in load balancing listeners to improve your service capability, which will not affect your normal business access.
- A load balancing listener supports four types of protocols: TCP, HTTP, HTTPS, and UDP.
- If the listener protocol is HTTPS, you need to bind a certificate. Note that you can upload a certificate or a certificate link.
- A load balancer allows you to flexibly configure multiple forwarding policies to achieve advanced forwarding controlling.
- Load balancing allows you to display real-time SLB business traffics and connections in monitoring data.

- Frontend network: In load balancing network services, a frontend network is used to provide VIP networks. Public networks, flat networks, and VPC networks can be used as frontend networks.
- Backend network: In load balancing network services, a backend network is used to create a private network for backend VM instances. Flat networks, vRouter networks, and VPC networks can be used as backend networks.
- Internet load balancing: A public network is used as the frontend network to
provide Internet-facing load balancing services through routers (VPC vRouters or
vRouters).
- A VPC network can be used as a backend network to provide Internet load balancing services based on a VPC network. In this scenario, multiple backend networks can be used. However, these backend networks must be attached to the same VPC vRouter.
- A vRouter network can be used as a backend network to provide Internet-facing load balancing services based on a vRouter network. In this scenario, make sure that the frontend network and the L3 network attached to the vRouter are the same.
- A flat network can be used as a backend network to provide Internet-facing load balancing services based on a flat network. In this scenario, the frontend network and the L3 network attached to the vRouter must be the same.
- Intranet load balancing (VPC private network): A VPC network is used as the
frontend network to provide intranet load balancing services through VPC
vRouters.
- A VPC network that shares the same VPC vRouter with a frontend network can be used as a backend network to provide intranet load balancing services based on VPC networks.
- In this scenario, multiple backend networks can be used. However, these backend networks must be attached to the same VPC vRouter.
- Intranet load balancing (flat network): A flat network is used as the frontend
network to provide intranet load balancing services through vRouters.
- A frontend network can be also used as a backend network to provide intranet load balancing services based on flat networks. In this scenario, the L3 network specified in the vRouter offering that is attached to the frontend network can be either a public network or a flat network.
- Other flat networks can be also used as a backend network to provide intranet load balancing services based on flat networks. In this scenario, the frontend network and the L3 network attached to the vRouter must be the same.
Note: To use intranet load balancing (flat network) services, attach a vRouter offering to the flat network in advance.
How to Use Load Balancing
- Create a load balancer.
- Create a listener and add it to the load balancer that you created in the preceding step. Then, specify the mapping between the public port and the VM port, and set the rules and algorithms.
- Select a VM NIC from a specified L3 network and attach the NIC to the listener for the load balancer to take effect.
Create Load Balancer
- Name: Enter a name for the load balancer.
- Description: Optional. Enter a description for the load balancer.
- Select VIP: Select a VIP. The load balancing service
is provided by a VIP.To use a VIP, select one of the following methods:
- Create new IP:To create a new VIP, set the following parameters:
- Network: Select the network
that provides a VIP. The network can be a public
network, a VPC network, or a flat network.
- The VIP created from a public network can be used to provide network services, such as EIP and load balancing, for flat networks.
- The VIP created from a public network can be used to provide network services, such as EIP, port forwarding, load balancing, and IPsec tunnel, for vRouter networks and VPC networks.
- The VIP created from a VPC network can be used to provide load balancing services for VPC networks.
- The VIP created from a flat network can be used to provide network services, such as EIP and load balancing, for flat networks.
- IP Range: Optional. Specify an IP range. Note that an IPv4 public network allows you to select a normal IP range or an IP address pool.
- Specified IP: Optional. Specify a VIP. If not specified, the system will automatically assign a VIP.
You can create a new VIP, as shown in Figure 2.Figure 2. Create new VIP
- Network: Select the network
that provides a VIP. The network can be a public
network, a VPC network, or a flat network.
- Use existing VIP:To use an existing VIP, set the following parameters:
- VIP: Select an existing VIP,
which can be a custom VIP or a system VIP.
- Custom VIP: Manually created by a user. You can create a public VIP, a VPC VIP, or a flat VIP as needed.
- System VIP: Automatically created by the system by using the L3 network attached by a router (vRouter or VPC vRouter) after the router is successfully created. Both public VIPs and flat VIPs can be created automatically by the system after a router is created.
You can use an existing VIP, as shown in Figure 3.Figure 3. Use existing VIP
- VIP: Select an existing VIP,
which can be a custom VIP or a system VIP.
- Create new IP:
- Listener: Optional. You can create a listener and add it to the load balancer directly when you create a load balancer, or you can create and add a listener after you create a load balancer.

Create Listener
Assume that you create a listener directly when creating a load balancer, and add the listener to the load balancer.
- Name: Enter a name for the listener.
- Description: Optional. Enter a description for the listener.
- Protocol: Select a protocol. Options: TCP | HTTP |
HTTPS | UDP.
- If you select TCP, HTTP, or UDP, ports 1-65535 are supported.
- If you select HTTPS, note that:
- Ports 1-65535 are supported.
- A certificate is required. You can upload a certificate or the link of a certificate. For information about how to upload and manage a certificate, see the Certificate topic.
- The Certificate parameter is required. You must attach a certificate to the listener when you select HTTPS.
- You can attach a certificate, as shown in Figure 5.
Figure 5. Attach a Certificate When Selecting HTTPS
- Load Balancer Port: Select a port between port 1 and port 65535 as the VIP port of the load balancer.
- VM Port: Select a port between port 1 and port 65535
as the VM port.
For example, if you set the load balancer port to 80, and the VM port to 5000, traffics to port 80 of the load balancer will be forwarded to port 5000 of the VM instance.
You can create a listener, as shown in Figure 6.Figure 6. Create Listener
- Advanced: Configure the advanced
options as needed.
- Health Check Protocol: Set the health check
protocol. Options: TCP | HTTP | UDP. The health check protocol can
be different from the listener protocol.
- If the listener protocol is TCP, HTTP, or HTTPS, the health check protocol can be TCP or HTTP.
- If the listener protocol is UDP, the health check protocol can be UDP.
- If you select HTTP, you can configure the normal status
code, health check path, and health check method.
- Normal Status Code: The HTTP status code when the health check passes. You can select more than one code as needed. Options: http_2xx | http_3xx | http_4xx | http_5xx.
- Health Check Path: The URI of
the page on which health checks are performed. For
example, /healthcheck.html. We
recommend that you set health check for static
pages. When you set a health check path, make sure
that:
- The health check path must be 2 to 80 characters long.
- The health check path can contain only letters, numbers, special symbols (-/.%?#&), or a combination of these three types of characters.
- The health check path must start with a forward slash (/).
- Health Check Method: Check whether the server application is healthy by sending a HEAD or GET request to simulate the access behavior of a browser. Default method: HEAD.
- Idle Connection Timeout: The amount of time that the load balancer terminates the connection between the server and the client when no data is transmitted. Default value: 60 seconds.
- Health Check Threshold: The number of consecutive health check successes required before considering an unhealthy VM instance healthy. Default value: 2.
- Health Check Port: Default value: default, indicating that the health check port is the same as that of the VM instance. You can also specify other ports as needed.
- Unhealth Check Threshold: The number of consecutive failed health checks required before considering a VM instance unhealthy. Default value: 2.
- Health Check Interval: The amount of time between health checks of an individual VM instance. Default value: 5 seconds.
- Max Connection: The maximum number of connections of the load balancer. Default value: 100000. Value range: 1-100,000.
- Load Balancer Algorithm: The routing
algorithm that the load balancer uses to handle data packets.
Default value: roundrobin (round robin).The supported load balancer algorithms are as follows:
- roundrobin (round robin)
Sequentially distributes external requests to VM instances specified by the load balancing algorithm. Each VM instance is treated equally without regardless of the actual number of connections and system load.
- leastconn (least number of connections)
Dynamically schedules network requests to the VM instances with the least number of established connections. If the servers (VM instances) in the cluster have similar system performance, the leastconn algorithm can balance the loads better.
- source (source hashing scheduling)
Finds out target servers from a hash table according to the source IP address (as hash key). If the target servers are available and not overloaded, requests will be sent to these servers. Otherwise, the response is null.
- weightroundrobin (weighted round robin)
Is a generalization of round robin scheduling, and distributes external requests to VM instances specified by the load balancing algorithm according the VM weight. VM instances with higher weight value have higher priority.
- roundrobin (round robin)
You can make advanced configurations when creating a listener, as shown in Figure 7.Figure 7. Create Listener - Advanced Configurations
- Health Check Protocol: Set the health check
protocol. Options: TCP | HTTP | UDP. The health check protocol can
be different from the listener protocol.
Bind VM NIC to Listener
- Network: Select a private network that has available
VM NICs. Make sure that the network meets the following requirements:
- The network is used to create a VM instance and has an available VM NIC.
- If you use a VIP created by using a public network to provide load
balancing services, select one of the following scenarios as
needed:
- Provide load balancing services based on VPC networks. In this scenario, the VPC networks must be attached to the same VPC vRouter, and the L3 network in the vRouter offering attached by the VPC vRouter must be the same as the public network on which the VIP is located.
- Provide load balancing services based on vRouter networks. In this scenario, the L3 network in the vRouter offering attached by the vRouter networks must be the same as the public network on which the VIP is located.
- Provide load balancing services based on flat networks. In this scenario, the L3 network in the vRouter offering attached by the flat networks must be the same as the public network on which the VIP is located.
- If you use a VIP created by using a VPC network to provide load balancing services, make sure that VPC network to be selected and the VPC network that provides the VIP are attached to the same VPC vRouter.
- If you use a VIP created by using a flat network to provide load
balancing services, the following scenarios are supported:
- The network you choose can be the flat network that was used to create a VIP. In this scenario, the L3 network in the vRouter offering is not enforced.
- The network you choose can be other flat networks. In this scenario, the L3 network in the vRouter offering must be the same as the flat network on which the VIP is located.
Note: If this listener is used by an elastic scaling group, make sure that the network you selected shares the same vRouter with the L3 network used by the elastic scaling group.
- VM NIC: Select a VM NIC.
Note: If you select weighted round robin for the load balancing algorithm, you can set the weight value. Value range: 0-100.

After the preceding configurations are successfully completed, the load balancer will send messages to the destination VM instances according to the specified forwarding policy.
Modify Listener Parameters
You can modify the following parameters of a listener: health check protocol, idle connection timeout, health check threshold, health check port, unhealthy check threshold, health check interval, maximum connection, and load balancer algorithm. If the health check protocol is HTTP, you can modify the normal status code, health check path, and health check method.


- The modification takes effect immediately.
- Modifying the parameters might cause the traffic interruption. We recommend that you stop the listener related businesses before making any modification.
- After the load balancing algorithm is changed to weighted round robin, the default weight of VM instances is 100. You can modify the weight value on the VM NIC tab page of the listener.
Load Balancer Operations
- Change name and description: Change the name and description of the load balancer.
- Create listener: Create a listener for the load balancer.
- Delete: Delete the load balancer. Note that the associated listeners and load balancing service will also be deleted. However, the related VIP and services associated with the VIP will not be affected.
- Audit: View related operations supported by the load balancer.
- Change name and description: Change the name and description of the listener.
- Bind VM NIC: Bind a VM NIC to the listener of a load balancer. Then, the VM instance becomes a load balancing resource that works according to the listener rule.
- Unbind VM NIC: Unbind a VM NIC from the listener. Note that the VM NIC will be removed from the load balancing pool.
- Set weight value: When the load balancing algorithm uses weighted round robin, set the weight value for the corresponding VM instances as needed. Value range: 0-100.
- Bind certificate: If the protocol of your listener is HTTPS, bind a certificate or a certificate link to your listener. Note that this operation is not supported if the listener type is TCP, HTTP, or UDP.
- Unbind certificate: If the protocol of your listener is HTTPS, you can unbind a certificate from the listener. Note that this operation is not supported if the listener type is TCP, HTTP, or UDP.
- Display the number of healthy VM instances: Display the number of healthy VM instances attached to the listener on the listener page. For example, healthy backend/total backend number.
- Monitoring data: Display the monitoring data, such as the sessions and inbound/outbound traffics, of the listener.
- Delete: Delete the listener. Note that the load balancing service provided by the listener will be automatically deleted.
- Audit: View related operations supported by the listener.
Constraints
- You can create more than one listener for a load balancer.
- The VM NICs bound to the listener of a load balancer must share the same L3 network.
- If the protocol of your listener is HTTPS, you can bind only one certificate to your listener at a time. To change your certificate, unbind the current one first.