After creating a Server Load Balancer instance, you have to add at least one listener and a group of backend servers to it.
In this tutorial, we will add one TCP listener and add two ECS instances deployed with web pages as the backend servers.
Log on to the Server Load Balancer console.
On the Instances page, click the ID of the target Server Load Balancer instance and enter the Details page.
On the left-side navigation pane, click Listeners and then click Add Listener.
Configure the listener as follows and use the default settings for other options:
Frontend Protocol [Port]: The front-end protocol and port of the Server Load Balancer system that is used to receive and distribute connection requests. Two port numbers cannot be the same in a Server Load Balancer instance.
In this tutorial, select the TCP protocol with port number 80.
Backend Protocol [Port]: The port that is opened on ECS instances to receive distributed requests. It can be the same in a Server Load Balancer instance.
In this tutorial, set the backend port number to 80.
Peak Bandwidth: You can set a peak bandwidth to limit the service capabilities that applications on the ECS instances can provide.
In this tutorial, you do not need to set the peak bandwidth because the instance is paid by traffic.
Scheduling Algorithm: Server Load Balancer supports the following scheduling algorithms. In this tutorial, the round-robin method is used.
Round robin: Requests are distributed evenly across the group of backend ECS servers sequentially.
Weighted round robin (WRR): You can set a weight for each backend server. Servers with higher weights receive more requests than those with lower weights.
Weighted least connections (WLC): In addition to the weight set to each backend ECS server, the number of connections to the client is also considered. A server with a higher weight value will receive a larger percentage of live connections at any one time. If the weights are the same, the system directs network connections to the server with the least number of established connections.
Click Next Step to configure health check settings. Select the TCP mode and keep other settings as default, and click Confirm.
Through health check on the backend ECS instances, Server Load Balancer can automatically block abnormal ECS instances and distribute requests to them again when they become normal.
Click Confirm to complete the configuration.
In the left-side navigation pane, click Servers > Backend Servers.
On the Load Balancer Server Pool page, click the Servers Not Added tab, select the previously created ECS instances, and then click Add in Batch.
In the Add a Backend Server dialog box, use the default weight value and click Confirm.
A server with a higher weight value receives more requests. The default weight value is 100.
Go back to the Instances page and click Refresh. When health check is Normal, the corresponding ECS instance can process requests forwarded by the Server Load Balancer instance normally.
In the web browser, enter the IP address of the Server Load Balancer instance to test the service.