All Products
Search
Document Center

Server Load Balancer:Add a TCP listener

Last Updated:Feb 06, 2024

If your services are sensitive to reliability, data consistency, and data integrity but can tolerate a relatively low transmission speed, such as file transmission, email services, and remote logon, you can add a TCP listener to your Classic Load Balancer (CLB) instance. The TCP listener can forward TCP requests to backend servers.

Prerequisites

A CLB instance is created. For more information, see Create and manage CLB instances.

Step 1: Add a TCP listener

  1. Log on to the CLB console.
  2. Select the region where the CLB instance is deployed.

  3. 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.

  4. In the Protocol & Listener step, configure the following parameters and click Next.

    Parameter

    Description

    Listener Protocol

    Select TCP.

    Backend Protocol

    If Listener Protocol is set to TCP, set Backend Protocol to TCP.

    Listener Port

    Specify the listener 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.

    Tag

    Select or enter a tag key and a tag value.

    Advanced Settings

    Click Modify to configure 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 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 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.

      Note

      Only high-performance CLB instances support consistent hashing.

    Session Persistence

    Specify whether to enable session persistence.

    After session persistence is enabled, the CLB instance forwards requests that are from the same 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.

    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) 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.

    Note

    IPv6 instances can be associated only with IPv6 ACLs. IPv4 instances can be associated only with IPv4 ACLs. For more information, see Create an ACL.

    Bandwidth Throttling

    Specify whether to set a maximum bandwidth for the listener.

    If the CLB instance is billed based on bandwidth usage, you can specify 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.

    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 a 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 if PrivateLink is used.

    Obtain Client Source IP Address

    Specify whether to preserve the 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. For more information, see Backend server overview.

  1. 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.

  2. In the Servers step, select the Elastic Compute Service (ECS) instances that you want to add and click Next.

  3. 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.

  4. 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 backend servers that are added to the same CLB instance.

  5. Click Next.

Step 3: Configure health checks

CLB checks the availability of backend servers by performing health checks. The health check feature improves overall service availability and reduces the impact of backend server failures.

Note

You cannot disable health checks for a listener that is associated with a primary/secondary server group.

  1. Optional: In the Health Check step, click Modify to modify the health check configuration.

    For more information, see Configure and manage CLB health checks.

  2. Click Next.

Step 4: Submit the configurations

  1. In the Confirm step, check the configurations of the listener. You can click Modify to modify the configurations.

  2. Confirm the configurations and click Submit.

  3. In the Configuration Successful message, click OK.

    After you configure the listener, you can view the listener on the Listener tab.

References