All Products
Search
Document Center

Enterprise Distributed Application Service:Use a shared SLB instance and listening ports to forward traffic

更新時間:Jul 12, 2023

You can associate a Server Load Balancer (SLB) instance with the instances of 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 forward traffic to multiple applications that are associated with the same SLB instance.

Background information

Note You can configure only HTTP listeners to forward traffic in Elastic Compute Service (ECS) clusters for applications that share the same port.

If multiple applications share the same SLB instance, the easiest traffic forwarding method is to configure different listening ports for different vServer groups. In the following figure, the vServer groups to which App1 and App2 belong correspond to listening ports 80 and 81. After the Classic Load Balancer (CLB) instance receives traffic, the CLB instance forwards the traffic based on the destination port. If the destination port is 80, the CLB instance forwards the traffic to vServer Group A of App1. If the destination port is 81, the CLB instance forwards the traffic to vServer Group B of App2.

erwtrg

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 forward traffic for the applications.

Configure listening ports to forward traffic

Procedure

The following procedure shows you how to associate a CLB instance with instances of two different applications and configure different listening ports to forward traffic:

  1. Create a CLB instance named edas-test-clb. For more information, see Create a CLB instance.
  2. In the Enterprise Distributed Application Service (EDAS) console, create an application that is deployed on an ECS cluster and name the application spring-cloud-provider. Associate edas-test-clb with the instances of spring-cloud-provider, and set the listening protocol to TCP and the listening port number to 80. For more information, see the procedure described in the Configure a dedicated SLB instance for an application topic.
  3. Associate edas-test-slb with the instances of spring-cloud-consumer. The associating process is similar to that of associating edas-test-slb with the instances of spring-cloud-provider. The only difference is that the listening port number for spring-cloud-consumer is 81.
    After you associate edas-test-slb with the instances of spring-cloud-provider and spring-cloud-consumer, you can access spring-cloud-provider by using http://123.1.XX.XX:80 and spring-cloud-consumer by using http://123.1.XX.XX:81 if the IP address of edas-test-slb is 123.1.XX.XX.

Associate the CLB instance with the instances of the first application and configure a listening port

If you use different listening ports of a CLB instance to forward requests to different applications, you need to associate the CLB instance with the instances of the applications and configure listening ports. This section describes how to perform these operations for the first application.

  1. Log on to the EDAS console. In the left-side navigation pane, choose Application Management > Applications.
  2. 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.
  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. In the AddLoad Balancing(Public) wizard, configure the CLB instance.
    1. In the Select SLB Instance step, select CLB for the SLBType parameter and select the CLB instance that you have created from the SLB (Internet) drop-down list. Click Next.
    2. In the Select and Configure Listener step, configure a listening port, and then click Next.
      • If you want to use an existing listening port that has been configured for the specified CLB instance, select Select Existing Listening Port and then select the listening port.
      • If no listening port is configured for the specified CLB instance or you want to add a listening port for the application, select Add Listening Port and then create a listener.

        Parameters

        ParameterDescription
        ProtocolSelect TCP. For more information about listeners and how to create a listener, see Add a TCP listener.
        Note TCP provides reliable and accurate content delivery at medium transfer speed. Therefore, TCP is suitable for scenarios such as file transfer, email exchange, and remote logons. If TCP is used, you cannot configure forwarding rules.
        Frontend Port NumberThe number of the port that is used by the CLB instance to provide external services.
        Important 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.
        Backend Port NumberThe port number of the application. The value is fixed.
    3. In the Configure vServer Group and Forwarding Policy step, configure a vServer group for the CLB instance, and then click Next.
      ParameterDescription
      Default Server GroupThe default server group does not support forwarding policies. Therefore, you cannot select the default server group if you use a port to forward traffic. You must select a vServer group.
      Existing VServer GroupIf you want to use an existing vServer group that has been created for the specified CLB instance, select Existing VServer Group and select the vServer group.
      Note A vServer group can be associated with the instances of only one application or application group.
      Create VServer GroupIf no vServer group is configured for the specified CLB instance or you want to configure a new vServer group, select Create VServer Group and specify the VServer Group Name parameter.
    4. In the Confirm step, check the SLB instance settings, and click Confirm.
  5. Check whether you can access the first application by using the IP address and port number of the associated CLB instance. For more information, see Verification.

Associate the CLB instance with the instances of the other application and configure a listening port

Log on to the EDAS console. On the Applications page, click the name of the second application. In the Application Settings section of the Basic Information tab, repeat the operations mentioned in the Associate the CLB instance with the instances of the first application and configure a listening port section of this topic. The CLB instance that you associate for the second application is the same as that for the first application. The only difference is the listening port.