Adding a UDP Listener

Scenarios

UDP listeners are suitable for scenarios that focus more on timeliness than reliability, such as video chat, games, and real-time information about the financial market.

You can add UDP listeners only to all shared load balancers and existing classic load balancers that work in the public network.

Adding a UDP Listener to a Shared 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. Click Service List. Under Network, click Elastic Load Balance.
  4. Locate the load balancer and click its name.
  5. Under Listeners, click Add Listener.
  6. Configure the listener based on Table 1 and click Next.
    Table 1 Parameters for configuring a listener

    Parameter

    Description

    Example Value

    Name

    Specifies the listener name.

    listener-pnqy

    Frontend Protocol/Port

    Specifies the protocol and port used by the load balancer to receive requests from clients and forward the requests to backend servers.

    Port range: 1 to 65535

    UDP/80

    Obtain Client IP Address

    Specifies whether to transmit the EIP bound to the load balancer to backend servers. This parameter is available when you have set Frontend Protocol to TCP or UDP.

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

    CAUTION:

    If you enable this option, you cannot change the specifications of backend servers.

    N/A

    Advanced Settings

    Access Policy

    Specifies how access to the listener is controlled. For more information, 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 IP Address Group.

    ipGroup-b2

    Description

    Provides supplementary information about the listener.

    N/A

  7. Set backend server group parameters by referring to Table 2 and health check parameters by referring to Table 3, and click Finish.
    Table 2 Parameters for configuring a backend server group

    Parameter

    Description

    Example Value

    Backend Server Group

    Specifies a group of servers that have the same features and receive requests from the load balancer. Two options are available:

    • Create new
    • Use existing
      NOTE:

      To associate an existing backend server group, ensure that it is not in use. Select the backend server group with the correct protocol. For example, if the frontend protocol is TCP, the backend protocol can only be TCP.

    Create new

    Name

    Specifies the name of the backend server group.

    server_group-sq4v

    Backend Protocol

    Specifies the protocol used by backend servers to receive requests. The backend protocol is UDP by default when you have set Frontend Protocol to UDP.

    Specifies the protocol used by backend servers to receive requests from the load balancer. Select either UDP or Quick UDP Internet Connection (QUIC).

    QUIC has the advantages of low latency, high reliability, and no head-of-line blocking (HOL blocking), and is very suitable for the mobile Internet. No new connections need to be established when you switch between a Wi-Fi and a mobile network.

    UDP

    Load Balancing Algorithm

    Specifies the algorithm used by the load balancer to distribute traffic.

    • Weighted round robin: Requests are distributed across backend servers in sequence based on their weights. Backend servers with higher weights receive proportionately more requests, whereas equal-weighted servers receive the same number of requests.
    • Weighted least connections: This algorithm is designed based on the least connections algorithm that uses the number of active connections to each backend server to make its load balancing decision. In addition to the number of connections, each server is assigned a weight based on its capacity. 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 allocates 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.
    • Connection ID: This algorithm is only available for dedicated load balancers when QUIC is used as the backend protocol. The connection ID in the packet is calculated using the consistent hash algorithm to obtain a specific value, and backend servers are numbered. The generated value determines to which backend server the requests are routed.
    NOTE:
    • Choose an appropriate algorithm based on your requirements for better traffic distribution.
    • For Weighted round robin or Weighted least connections, no access request will be routed to a server if its weight is 0.

    Weighted round robin

    Sticky Session

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

    NOTE:

    Sticky sessions can be enabled only if you select 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 UDP is used as the frontend protocol.

    Requests with the same source IP address are routed to the same backend server during the session.

    Source IP address

    Stickiness Duration (min)

    Specifies the minutes that sticky sessions are maintained. Set the stickiness duration when you have selected Weighted round robin and enabled sticky sessions. The stickiness duration ranges from 1 to 60.

    20

    Description

    Provides supplementary information about the backend server group.

    N/A

    Table 3 Parameters for configuring a health check

    Parameter

    Description

    Example Value

    Enable Health Check

    Specifies whether to enable health checks.

    N/A

    Protocol

    Specifies the protocol used by the load balancer to perform health checks on backend servers. The health check protocol is UDP by default.

    UDP

    Port

    Specifies the port used by the load balancer to perform health checks on backend servers.

    Port range: 1 to 65535

    NOTE:

    This parameter is optional. If you do not specify a health check port, the port of each backend server will be used for health checks by default.

    80

    Advanced Settings

    Interval (s)

    Specifies the maximum time between health checks, 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.

    10

    Maximum Retries

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

    3

  8. Click OK.

Adding a UDP Listener to a Classic 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. Click Service List. Under Network, click Elastic Load Balance.
  4. In the classic load balancer list, locate the load balancer and click its name.
  5. Under Listeners, click Add Listener. In the Add Listener dialog box, specify the parameters by referring to Table 4.
    Table 4 Parameter description

    Parameter

    Description

    Example Value

    Name

    Specifies the listener name.

    listener-ssgu

    Frontend Protocol/Port

    Specifies the protocol and port used by the load balancer to receive requests from clients and forward the requests to backend servers.

    UDP is available only for load balancers working in a public network, and the port numbers range from 1 to 65535.

    UDP/80

    Backend Protocol/Port

    Specifies the protocol and port used by backend servers to receive requests.

    The protocol is UDP by default, and the port numbers range from 1 to 65535.

    UDP/22

    Load Balancing Algorithm

    Specifies the algorithm used by the load balancer to distribute traffic.

    • Round robin: Requests are distributed sequentially across all servers, so that the load is evenly shared.
    • Least connections: a dynamic scheduling algorithm that estimates backend server load based on the number of active connections. Requests are routed to servers with the minimum number of connections.
    • 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 allocates 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.

    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.

    NOTE:

    You can enable sticky sessions only if you have set Load Balancing Algorithm to Round robin.

    N/A

    Stickiness Duration (min)

    Specifies the minutes that sticky sessions are maintained. The stickiness duration ranges from 1 to 1440.

    5

    Description

    Provides supplementary information about the listener.

    N/A

    Health Check Protocol/Port

    Specifies the protocol and port used for performing health checks on backend servers.

    The protocol is UDP by default, and the port numbers range from 1 to 65535.

    NOTE:

    When UDP is used for health checks, security group rules of the backend servers must allow access using Internet Control Message Protocol (ICMP).

    UDP/80

    Interval (s)

    Specifies the maximum time between health checks, 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.

    10

    Healthy Threshold

    Specifies the number of consecutive health checks necessary for a backend server to be considered healthy. The threshold ranges from 1 to 10.

    3

    Unhealthy Threshold

    Specifies the number of consecutive health checks necessary for a backend server to be considered unhealthy. The threshold ranges from 1 to 10.

    3

  6. Click OK.