Updated on 2024-04-19 GMT+08:00

Adding a TCP Listener

Scenarios

You can add a TCP listener, if high reliability and high accuracy are required but slow speed is acceptable, for example, during file transfer, email sending and receiving, and remote login.

Constraints

  • If the listener protocol is TCP, the protocol of the backend server group is TCP by default and cannot be changed.
  • If you only select application load balancing (HTTP/HTTPS) for your dedicated load balancer, you cannot add a TCP listener to this load balancer.

Adding a TCP Listener to a Dedicated Load Balancer

  1. Log in to the management console.
  2. In the upper left corner of the page, click and select the desired region and project.
  3. Hover on in the upper left corner to display Service List and choose Network > Elastic Load Balance.
  4. Locate the load balancer and click its name.
  5. Under Listeners, click Add Listener. Configure the parameters based on Table 1.
    Table 1 Parameters for configuring a listener

    Parameter

    Description

    Example Value

    Name

    Specifies the listener name.

    listener-pnqy

    Frontend Protocol

    Specifies the protocol that will be used by the load balancer to receive requests from clients.

    TCP

    Frontend Port

    Specifies the port that will be used by the load balancer to receive requests from clients.

    The port number ranges from 1 to 65535.

    80

    Access Control

    Specifies how access to the listener is controlled. For details, see Access Control. The following options are available:

    • All IP addresses
    • Blacklist
    • Whitelist

    Blacklist

    IP Address Group

    Specifies the IP address group associated with a whitelist or blacklist. If there is no IP address group, create one first. For more information, see Creating an IP Address Group.

    ipGroup-b2

    Transfer Client IP Address

    Specifies whether to transmit IP addresses of the clients to backend servers.

    This function is enabled for dedicated load balancers by default and cannot be disabled.

    N/A

    Advanced Settings

    Idle Timeout

    Specifies the length of time for a connection to keep alive, in seconds. If no request is received within this period, the load balancer closes the connection and establishes a new one with the client when the next request arrives.

    The idle timeout duration ranges from 10 to 4000.

    300

    Description

    Provides supplementary information about the listener.

    You can enter a maximum of 255 characters.

    N/A

  6. Click Next: Configure Request Routing Policy to configure the backend server group. For details about how to configure a backend server group, see Table 2.
    Table 2 Parameters for configuring a backend server group

    Parameter

    Description

    Example Value

    Backend Server Group

    Specifies a group of servers with the same features to receive requests from the load balancer. Two options are available:

    • Create new
    • Use existing
      NOTE:

      The backend protocol of the backend server group must match the frontend protocol. For example, if the frontend protocol is TCP, the backend protocol must be TCP.

    Create new

    Backend Server Group Name

    Specifies the name of the backend server group.

    server_group

    Backend Protocol

    Specifies the protocol used by backend servers to receive requests.

    The backend protocol is TCP by default and cannot be changed.

    TCP

    Load Balancing Algorithm

    Specifies the algorithm used by the load balancer to distribute traffic. The following options are available:

    • Weighted round robin: Requests are routed to different servers based on their weights, which indicate server processing performance. Backend servers with higher weights receive proportionately more requests, whereas equal-weighted servers receive the same number of requests.
    • Weighted least connections: In addition to the number of active connections established with each backend server, each server is assigned a weight based on their processing capability. Requests are routed to the server with the lowest connections-to-weight ratio.
    • Source IP hash: The source IP address of each request is calculated using the consistent hashing algorithm to obtain a unique hash key, and all backend servers are numbered. The generated key is used to allocate the client to a particular server. This allows requests from different clients to be routed based on source IP addresses and ensures that a client is directed to the same server that it was using previously.
    NOTE:
    • Choose an appropriate algorithm based on your requirements for better traffic distribution.
    • For Weighted round robin or Weighted least connections, no requests will be routed to a server with a weight of 0.

    Weighted round robin

    Sticky Session

    Specifies whether to enable sticky sessions. If you enable sticky sessions, all requests from a client during one session are sent to the same backend server.

    This parameter is optional and can be enabled if you have selected Weighted round robin or Weighted least connections for Load Balancing Algorithm.

    N/A

    Sticky Session Type

    Specifies the type of sticky sessions.

    Source IP address is the only choice available when TCP or UDP is used as the frontend protocol.

    Source IP address: The source IP address of each request is calculated using the consistent hashing algorithm to obtain a unique hash key, and all the endpoints are numbered. The system allocates the client to a particular endpoint based on the generated key. Requests from the same IP address are forwarded to the same backend server for processing.

    Source IP address

    Stickiness Duration (min)

    Specifies the minutes that sticky sessions are maintained. You can enable sticky sessions only if you select Weighted round robin or Weighted least connections for Load Balancing Algorithm.

    • Stickiness duration at Layer 4: 1 to 60
    • Stickiness duration at Layer 7: 1 to 1440

    20

    Description

    Provides supplementary information about the backend server group.

    You can enter a maximum of 255 characters.

    N/A

  7. Click Next: Add Backend Server. Add backend servers and configure the health check for the backend server group. For details about how to add backend servers, see Overview. For the parameters required for configuring a health check, see Table 3.
    Table 3 Parameters for configuring a health check

    Parameter

    Description

    Example Value

    Health Check

    Specifies whether to enable health checks.

    If the health check is enabled, click next to Advanced Settings to set health check parameters.

    N/A

    Health Check Protocol

    Specifies the protocol that will be used by the load balancer to check the health of backend servers.

    If the backend protocol is TCP, the health check protocol can be TCP, HTTP, or HTTPS.

    HTTP

    Domain Name

    Specifies the domain name that will be used for health checks. This parameter is mandatory if the health check protocol is HTTP or HTTPS.

    • You can use the private IP address of the backend server as the domain name.
    • You can also specify a domain name that consists of at least two labels separated by periods (.). Use only letters, digits, and hyphens (-). Do not start or end strings with a hyphen. Max total: 100 characters. Max label: 63 characters.

    www.elb.com

    Health Check Port

    Specifies the port that will be used by the load balancer to check the health of backend servers. The port number ranges from 1 to 65535.

    NOTE:

    By default, the service port on each backend server is used. You can also specify a port for health checks.

    80

    Path

    Specifies the health check URL, which is the destination on backend servers for health checks. This parameter is mandatory if the health check protocol is HTTP or HTTPS. The path can contain 1 to 80 characters and must start with a slash (/).

    /index.html

    Interval (s)

    Specifies the interval for sending health check requests, in seconds.

    The interval ranges from 1 to 50.

    5

    Timeout (s)

    Specifies the maximum time required for waiting for a response from the health check, in seconds. The timeout duration ranges from 1 to 50.

    3

    Maximum Retries

    Specifies the maximum number of health check retries. The value ranges from 1 to 10.

    3

  8. Click Next: Confirm.
  9. Confirm the configuration and click Submit.