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 create a TCP listener and add the ECS instances that have deployed web pages as the backend servers.
Log on to the Server Load Balancer console.
On the Instance Management page, click the ID of the target Server Load Balancer instance.
On the left-side navigation pane, click Listener 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. The port number 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 number that is opened on the ECS instances to receive the distributed requests. The port number can be the same in a Server Load Balancer instance.
In this tutorial, set to 80.
Peak Bandwidth: You can set a peak bandwidth to limit the service capabilities that the application of the ECS instance can provide.
In this tutorial, no need to set the peak bandwidth because the instance is payed 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 the 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 less 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. The servers 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, click Confirm.
Through health check on 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.
On the left-side navigation pane, click Server > Backend Server.
On the Load Balancer Server Pool page, click the Servers Not Added tab and select the previously created ECS instances, then click Add in Batch.
In the Add a Backend Server dialog, use the default weight value and click Confirm.
The higher the weight, the more requests are received.
Go back to the Instance Management page, click Refresh. When the health check is Normal, you can send requests to the Server Load Balancer instance.
In the web browser, enter the IP address of the Server Load Balancer instance to test the service.