TCP provides reliable and accurate content delivery at relatively low connection speeds. Therefore, TCP is suitable for file transmission, email sending or receiving, and remote logons. You can add a TCP listener to forward TCP requests.
A Classic Load Balancer (CLB) instance is created. For more information, see Create and manage a CLB instance.
Step 1: Configure a TCP listener
- Log on to the CLB console.
In the top navigation bar, select the region where the CLB instance resides.
Use one of the following methods to open the listener configuration wizard:
On the Instances page, find the CLB instance that you want to manage and click Configure Listener in the Actions column.
On the Instances page, find the CLB instance that you want to manage and click the ID of the instance. On the instance details page, click the Listener tab and click Add Listener.
In the Protocol & Listener step, configure the following parameters and click Next.
If Listener Protocol is set to TCP, Backend Protocol is set to TCP.
Specify the listener port that is used to receive and forward requests to backend servers. Valid values: 1 to 65535.
Enter a name for the listener.
Select or enter a tag key and a tag value.
Click Modify to configure advanced settings.
Select a scheduling algorithm.
Weighted Round-robin (WRR): Backend servers that have higher weights receive more requests than backend servers that have lower weights.
Round Robin (RR): Requests are sequentially distributed to backend servers.
Consistent Hashing (CH):
Four-element: specifies consistent hashing that is based on four factors: source IP address, destination IP address, source port, and destination port. Requests that contain the same information based on the four factors are distributed to the same backend server.
Source IP: specifies consistent hashing that is based on source IP addresses. Requests from the same source IP address are distributed to the same backend server.
Only high-performance CLB instances support consistent hashing.
Specify whether to enable session persistence.
After session persistence is enabled, the CLB instance forwards all requests from a client to the same backend server.
For TCP listeners, session persistence is implemented based on IP addresses. Requests from the same IP address are forwarded to the same backend server.
Specify whether to enable access control.
Select an access control method after you enable access control. Then, select an access control list (ACL) that is used as the whitelist or blacklist of the listener.
- Whitelist: allows access from specific IP addresses. Only requests from the IP addresses or CIDR blocks specified in the network ACL are forwarded. Whitelists apply to scenarios in which you want to allow access only from specific IP addresses. Your service may be adversely affected if the whitelist is not properly configured. After a whitelist is configured, only requests from IP addresses that are added to the whitelist are forwarded by the listener.
If a whitelist is configured but no IP address is added to the whitelist, the listener forwards all requests.
- Blacklist: denies access from specific IP addresses. Requests from the IP addresses or CIDR blocks specified in the network ACL are denied. Blacklists apply to scenarios in which you want to deny access from specific IP addresses.
If a blacklist is configured but no IP address is added to the blacklist, the listener forwards all requests.
IPv6 CLB instances can be associated only with IPv6 ACLs. IPv4 CLB instances can be associated only with IPv4 ACLs. For more information, see Create an ACL.
Bandwidth Throttling for Listeners
Specify whether to set the maximum bandwidth of the listener.
If a pay-by-bandwidth CLB instance is used, you can set the maximum bandwidth of each listener to limit the amount of network traffic forwarded by listeners. The sum of the maximum bandwidth of all listeners that are added to a CLB instance cannot exceed the maximum bandwidth of the CLB instance. By default, this feature is disabled and all listeners share the bandwidth of the CLB instance.Important
For example, the maximum bandwidth of an Internet-facing CLB instance is 5 Mbit/s, and you configure two listeners. You allocate 5 Mbit/s of bandwidth to Listener A, and do not allocate bandwidth to Listener B. In this case, Listener B is inaccessible. Exercise caution when you allocate bandwidth.
If three listeners are configured for an internal-facing CLB instance, and the total bandwidth allocated to Listener A and Listener B is 5,120 Mbit/s, Listener C is inaccessible. Exercise caution when you allocate bandwidth.
If a pay-by-data-transfer CLB instance is used, the bandwidth of listeners is unlimited by default.
Connection Timeout Period
Specify the timeout period for a TCP connection.
Specify whether to use the Proxy protocol to pass client IP addresses to the backend servers.Note
You cannot enable this feature if PrivateLink is used.
Obtain Client Source IP Address
Specify whether to retrieve the real IP addresses of clients. Only Layer 4 listeners support this feature. By default, this feature is enabled.
Automatically Enable Listener
Specify whether to immediately enable the listener after it is created. By default, listeners are enabled after they are created.
Step 2: Add backend servers
After you configure the listener, you must add backend servers to process client requests. You can use the default server group that is configured for the CLB instance. You can also configure a vServer group or a primary/secondary server group, or enable the primary/secondary mode for the listener. For more information, see Backend server overview.
In the Backend Servers step, select the type of the backend server group to which requests are forwarded. In this example, the default backend server group is used.
Select Default Server Group and click Add More.
In the Servers step, select the Elastic Compute Service (ECS) instances that you want to add and click Next.
In the Ports/Weights step, configure the weights of the backend servers. ECS instances that have higher weights receive more requests.Note
If the weight of a backend server is set to 0, no request is distributed to the backend server.
Click Add. Specify the port that is used by the backend server to receive requests. Valid values: 1 to 65535.
You can specify the same port for different backend servers that are added to a CLB instance.
Step 3: Configure health checks
CLB performs health checks to check the availability of backend ECS instances. The health check feature improves overall service availability and reduces the impact of backend server failures.
You cannot disable health checks for a listener that is associated with a primary/secondary server group.
Optional: In the Health Check step, click Modify to modify the health check configuration.
For more information, see Configure and manage health checks.
Step 4: Submit the configurations
In the Confirm step, check the configurations of the listener. You can click Modify to modify the configurations.
Confirm the configurations and click Submit.
After Configuration Successful appears, click OK.
After you configure the listener, you can view the listener on the Listener tab.
CreateLoadBalancerTCPListener: creates a TCP listener for a CLB instance.