You can bind a Server Load Balancer (SLB) instance to multiple applications to save costs. These applications share a public IP address and domain name. You can configure forwarding policies to forward requests to the applications. This topic describes how to configure listening ports to distribute traffic for multiple applications that are bound to the same SLB instance.

Prerequisites

An SLB instance is created. For more information, see Create a CLB instance.

Background information

Note You can configure only HTTP listeners to distribute traffic in Elastic Compute Service (ECS) clusters.

For example, you have two applications. One is the User application that is used to query orders. The other is the Order application that is used for user logon. Both applications use the same public IP address and domain name. You can configure different listening ports to distribute traffic for the applications.

Configure listening ports to distribute traffic

Bind an SLB instance to an application and configure a listening port

You need to bind an SLB instance to an application and configure a listening port for the application.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications.
  3. On the Applications page, select a region in the top navigation bar and an option from the Microservice Namespace drop-down list. Select ECS Clusters from the Cluster Type drop-down list. Then, click the name of the required application in the application list.
  4. In the Application Settings section of the Basic Information page, click Add next to SLB (Internet).
    Note If you have configured an SLB instance, the IP address and port number of the SLB instance are displayed. You can click Modify to go to the configuration page and modify the settings of the SLB instance. You can also click Unbind to unbind the SLB instance.
  5. Configure the SLB instance in the Bind SLB Instance to Application wizard.
    1. In the Select SLB step, select the SLB instance that you have created from the SLB (Internet) drop-down list, and then click Next.
    2. In the Select and Configure Listener step, configure a listening port, and then click Next.
      • If you want to use a listening port that is configured for the specified SLB instance, select Select Existing Listening Port and select an existing listening port.
        Note If you bind an SLB instance to multiple applications, you must select a listening port when you configure listening ports to distribute traffic. Make sure that the listening port is not bound to another application.
      • If no listening port is configured for the specified SLB instance or you want to add a listening port to the application, select Add Listening Port and then create a listener.

        Parameters

        Parameter Description
        Protocol TCP and HTTP are supported. Select a protocol as needed. For more information, see Listener overview.
        Frontend Port Number The number of the port that is used by the SLB instance to provide services.
        Notice If the port number that you want to add is used by another listening protocol, you must set another port number. You can also log on to the SLB console to remove the listening port, and then add the port in the EDAS console.
        Health Check Path (URI) The URI that is used by the SLB instance to check the status of the backend. Enter a valid URI. For more information, see Configure health check.
        Backend Port Number The port number of the application. The value is fixed.
    3. In the Configure VServer Groups and Forwarding Policies step, configure a vServer group for the SLB instance, and then click Next.
      Note If you bind an SLB instance to multiple applications and distribute traffic by using different listening ports, you do not need to configure forwarding policies.
      • If no vServer group is available, all requests are forwarded to ECS instances that reside in the default server group.
        Note The default server group does not support forwarding policies.
      • If you need to configure forwarding policies, you must use vServer groups. You can use the following methods to configure vServer groups for applications:
        • If you want to use a vServer group that is created for the specified SLB instance, select Existing VServer Group and select an existing vServer group.
          Notice A vServer group can be bound to only one application or instance group.
        • If no vServer group is configured for the specified SLB instance or you want to configure a new vServer group, select Create VServer Group and set the VServer Group Name parameter.
    4. In the Confirm SLB Change step, check the settings of the SLB instance. Then, click Confirm.
  6. Check whether the IP address and port number of the bound SLB instance can access the current application. For more information, see Verify results.

Bind an SLB instance to the other application and configure a listening port

You need to bind the same SLB instance to the other application and configure a different listening port for the application.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. In the upper part of the page, select a namespace. On the Applications page, click the name of the desired application.
  3. In the Application Settings section of the Basic Information page, click Add next to SLB (Internet).
    Note If you have configured an SLB instance, the IP address and port number of the SLB instance are displayed. You can click Modify to go to the configuration page and modify the settings of the SLB instance. You can also click Unbind to unbind the SLB instance.
  4. Configure the SLB instance in the Bind SLB Instance to Application wizard.
    1. In the Select SLB step, select the SLB instance that you have created from the SLB (Internet) drop-down list, and then click Next.
    2. In the Select and Configure Listener step, select Add Listening Port, create a listener for the SLB instance, and then click Next.

      Parameters

      Parameter Description
      Protocol TCP and HTTP are supported. Select a protocol as needed. For more information, see Listener overview.
      Frontend Port Number The number of the port that is used by the SLB instance to provide services.
      Notice If the port number that you want to add is used by another listening protocol, you must set another port number. You can also log on to the SLB console to remove the listening port, and then add the port in the EDAS console.
      Health Check Path (URI) The URI that is used by the SLB instance to check the status of the backend. The default value is /_ehc.html. Enter a valid URI. For more information, see Configure health check.
      Backend Port Number The port number of the application. The value is fixed.
    3. In the Configure VServer Groups and Forwarding Policies step, configure a vServer group for the SLB instance, and then click Next.
      Note If you bind an SLB instance to multiple applications and distribute traffic by using different listening ports, you do not need to configure forwarding policies.

      The default server group or vServer group of an SLB instance can be bound to only one application or instance group. Make sure that the server groups bound to the applications are different. Otherwise, an error may occur when the SLB instance is bound to the applications. Therefore, we recommend that you select Create VServer Group and set the VServer Group Name parameter to create a vServer group for the current application.

    4. In the Confirm SLB Change step, check the settings of the SLB instance. Then, click Confirm.
  5. Check whether the IP address and port number of the bound SLB instance can access the current application. For more information, see Verify results.