Server Load Balancer (SLB) is a preferred service for traffic distribution in Alibaba Cloud. SLB offers high availability, scalability, cost efficiency, security, and high concurrency. You can bind an SLB instance to an Enterprise Distributed Application Service (EDAS) application. Then, the EDAS application uses the SLB instance as the traffic ingress, and the SLB instance uses the application instances as backend servers. The SLB instance distributes traffic to different application instances based on a forwarding policy.

Background information

EDAS supports managed applications that are deployed in Alibaba Cloud Elastic Compute Service (ECS) clusters and hybrid cloud ECS clusters. You can deploy Java microservices such as Spring Cloud, Dubbo, and High-speed Service Framework (HSF) applications in ECS clusters. After an application is created in EDAS, the instances of the application must provide services as a whole. Therefore, a unified traffic ingress is required for the application, and a traffic distribution service is required to distribute access traffic to different application instances based on a forwarding policy.

BV

An EDAS application uses an SLB instance as the traffic ingress, and the SLB instance uses the application instances as backend servers. The SLB instance distributes traffic to the application instances based on a forwarding policy. The following figure shows the binding relationships between EDAS applications and SLB instances.

BH

You can bind an SLB instance to an application that is deployed on multiple instances. This ensures high availability of the application, reduces the load on each instance, and implements traffic distribution. The SLB instance allows you to configure algorithms for scheduling backend servers, such as round-robin and weighted round-robin algorithms. If you enable the session persistence feature, requests from a client can be forwarded to the same backend server of the application. This improves access performance.

GHHJK

EDAS allows you to jointly use Internet-facing SLB instances and internal-facing SLB instances to access EDAS applications in an ECS cluster. You can use Internet-facing SLB instances to provide access to web applications over the Internet and use internal-facing SLB instances to provide access to backend applications over the internal network. This separates the frontend web applications from the backend applications. In addition, backend servers can be separately scaled for the frontend web applications and backend applications based on the performance requirements.

GHNB

Listeners on an SLB instance are created based on ports. You can enable multiple applications to share an SLB instance based on different listeners by configuring vServer groups for the applications. In addition, Layer 7 SLB instances allow you to configure forwarding policies based on domain names and URLs.

dsfsfdfds

You can deploy applications in different regions and bind SLB instances to the applications to implement cross-region disaster recovery for the applications. You need to deploy SLB instances in different regions and attach ECS instances of different zones within the same region to an SLB instance. You can use Alibaba Cloud DNS to resolve domain names to the service addresses of SLB instances in different regions. This way, you can globally balance the load. If a region becomes unavailable, you can temporarily stop DNS resolution in the region without affecting user access.

SLB instances can prevent DDoS attacks such as SYN flood, UDP flood, ACK flood, ICMP flood, and DNS flood. In addition, Layer 7 SLB instances allow you to integrate Web Application Firewall (WAF) with a few clicks to provide a more reliable application layer.

EDAS allows you to use SLB instances in one of the following ways:
  • Bind an SLB instance to a single application.
  • Bind an SLB instance to multiple applications.

In the following examples, an Internet-facing SLB instance is used to describe how to use SLB instances. The method for using an Internet-facing SLB instance also applies to an internal-facing SLB instance. The difference lies in the selection of the network environment.

Bind an SLB instance to a single application

You can bind an SLB instance to a single application in the EDAS console. This way, the SLB instance is exclusively used by the application. The following figure shows an EDAS cluster in which two applications named App1 and App2 are deployed. App1 contains three instances, and App2 contains two instances. You can bind an SLB instance to each of the applications. When you bind an SLB instance to an application in the EDAS console, EDAS creates a vServer group for the application and adds the ECS instances of the application to the vServer group.

The resources and bandwidth of each SLB instance are exclusive to an application. The queries per second (QPS) performance of an application depends on the specifications of the SLB instance.

  1. Create an SLB instance. In this example, the SLB instance is named edas-test-slb. For more information, see Create a CLB instance.
  2. Log on to the EDAS console to create an application of the ECS Clusters type. In this example, the application is named spring-cloud-provider.
  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 application whose metrics you want to view.
  4. On the Application Overview page, click the Plus icon icon next to SLB (Public Network) in the Access configuration section.
  5. In the Select SLB step of the Bind SLB Instance to Application wizard, set the SLB (Internet) parameter to the SLB instance that you created in Step 1.
  6. In the Select and Configure Listener step, select Add Listening Port and set the Protocol parameter to TCP and the Frontend Port Number parameter to 80.
  7. Configure the vServer group and forwarding policy.
  8. Click Confirm.

    After you bind the SLB instance to the application, you can view the endpoint and port of the SLB instance on the Basic Information tab of the application. You can also modify or unbind the SLB instance.

    For more information about how to bind an SLB instance to a single application in EDAS, see Configure a dedicated SLB instance for an application.

Bind an SLB instance to multiple applications

To reduce the costs and the number of SLB instances, EDAS allows you to bind an SLB instance to multiple applications. The following figure shows an EDAS cluster in which two applications named App1 and App2 are deployed. App1 contains three instances, and App2 contains two instances. You can bind an SLB instance to the two applications. When you bind an SLB instance to the applications in the EDAS console, EDAS creates a vServer group for each application and adds the ECS instances of the applications to the vServer groups. The resources and bandwidth of the SLB instance are shared among the applications.

dtyh

The SLB instance can distribute inbound traffic to different vServer groups based on the traffic forwarding policies. This way, the traffic is distributed to different applications, as shown in the preceding figure.

EDAS allows you to distribute traffic based on the following rules:

  • Distribute traffic based on listener ports.
  • Distribute traffic based on domain names or URLs.

Distribute traffic based on listener ports

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

erwtrg

The following procedure shows you how to bind an SLB instance to two different applications and configure different listener ports to distribute traffic:

  1. Create an SLB instance. In this example, the SLB instance is named edas-test-slb. For more information, see Create a CLB instance.
  2. Create two applications of the ECS Clusters type in the EDAS console. In this example, the two applications are named spring-cloud-provider and spring-cloud-consumer.
  3. Bind edas-test-slb to spring-cloud-provider. The binding process is the same as that of binding edas-test-slb to spring-cloud-provider in the "Bind an SLB instance to a single application" section of this topic. Set the listener protocol to TCP and the listener port number to 80. Create a vServer group named spring-cloud-provider.
  4. Bind edas-test-slb to spring-cloud-consumer. The binding process is similar to that of binding edas-test-slb to spring-cloud-provider. The only difference is that the listener port number for spring-cloud-consumer is 81.

After you bind edas-test-slb to 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.

For more information, see Use a shared SLB instance and listening ports to distribute traffic.

Distribute traffic based on domain names or URLs

SLB instances support the HTTP protocol and can distribute traffic based on the domain names and URLs in HTTP requests. In the following figure, the IP address of the SLB instance is mapped to the following domain names that are bound to the vServer groups of App1 and App2: abc***.com and xyz***.com. After the SLB instance receives traffic, the SLB instance distributes traffic based on the domain name in the HTTP request. The SLB instance distributes traffic to vServer Group A of App1 if the domain name is abc***.com and to vServer Group B of App2 if the domain name is xyz***.com.

JJHKH

The following procedure shows you how to bind an SLB instance to two different applications and configure different domain names to distribute traffic:

  1. Create an SLB instance. In this example, the SLB instance is named edas-test-slb. For more information, see Create a CLB instance.
  2. Create two applications of the ECS Clusters type in the EDAS console. In this example, the two applications are named spring-cloud-provider and spring-cloud-consumer.
  3. Bind edas-test-slb to spring-cloud-provider. The binding process is the same as that of binding edas-test-slb to spring-cloud-provider in the "Bind an SLB instance to a single application" section of this topic. Set the listener protocol to HTTP and the listener port number to 80. Create a vServer group named provider.test.com.
  4. Bind edas-test-slb to spring-cloud-consumer. The binding process is similar to that of binding edas-test-slb to spring-cloud-provider. The only difference is that the vServer group you create for spring-cloud-consumer is named consumer.test.com.

After you bind edas-test-slb to spring-cloud-provider and spring-cloud-consumer, you can add the following entries to the /etc/hosts file on your Linux or macOS client if the IP address of the SLB instance is 123.1.XX.XX.

123.1.XX.XX provider.test.com
123.1.XX.XX consumer.test.com

Then, you can use http://provider.test.com to access spring-cloud-provider and http://consumer.test.com to access spring-cloud-consumer.

For more information about how to bind an SLB instance to multiple applications for traffic distribution based on domain names or URLs, see Use a shared SLB instance and dedicated domain names or URLs to distribute traffic.