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 is deployed.
- 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 then click Add Listener.
- On the Protocol and Listener wizard page, set the following parameters and click Next.
Parameter Description Select Listener Protocol Select TCP. Listening Port Specify the listening port that is used to receive and forward requests to backend servers. Valid values: 1 to 65535. Listener Name Enter a name for the listener. Advanced You can click Modify to configure the advanced settings. Scheduling Algorithm 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 Hash (CH):
Note Only high-performance CLB instances support the CH algorithm.
- Tuple: 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.
Enable Session Persistence Specify whether to enable session persistence.
After session persistence is enabled, CLB 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.
Enable Access Control 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.
Note IPv6 CLB instances can be associated only with IPv6 ACLs, while IPv4 CLB instances can be associated only with IPv4 ACLs. For more information, see Create a network ACL.
- 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.
Enable Peak Bandwidth Limit
Specify whether to set the maximum bandwidth of the listener.
If the CLB instance is billed based on bandwidth usage, you can set different maximum bandwidth values for different listeners. This limits the amount of traffic that can be forwarded by each listener. 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.Note If a CLB instance is billed based on data transfer, the bandwidth of its listeners is not limited by default.
Idle Timeout Specify the timeout period for a TCP connection. Proxy Protocol Specify whether to use the Proxy protocol to pass client IP addresses to the backend servers.Note You cannot enable this feature in scenarios where 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 After Creation 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.
- On the Backend Servers wizard page, select the type of the server group to which requests are forwarded.
The default server group is used in this example.
Select Default Server Group and click Add More.
- In the My Servers panel, select the ECS instances that you want to add as backend servers and click Next.
- On the Ports/Weights wizard page, specify the weights of the backend servers that you added. A backend
server with a higher weight receives more requests. Note If the weight of a backend server is set to 0, no request is distributed to the backend server.
- Click Add. You can specify ports for the backend ECS instances to receive requests based on
your business requirements. Valid values: 1 to 65535.
You can specify the same port for different backend servers that are added to a CLB instance.
- Click Next.
Step 3: Configure health checks
- Optional:On the Health Check wizard page, click Modify to modify the health check configurations. For more information, see Configure and manage health checks.
- Click Next.
Step 4: Submit the configurations
- On the Confirm Configurations wizard page, confirm the configurations. You can click Modify to modify the configurations.
- After you confirm the configurations, click Submit.
- After the configurations are submitted, 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.