You can associate Server Load Balancer (SLB) instances with your scaling group to distribute incoming traffic across the instances in the scaling group. This improves the performance of your scaling group. You can associate or disassociate SLB instances with or from your scaling group in the Auto Scaling console or by calling the AttachLoadBalancers or DetachLoadBalancers API operation.

Background information

In this topic, Classic Load Balancer (CLB) instances, a type of SLB instances, are used. After you associate CLB instances with your scaling group, the instances that are automatically created in your scaling group or the instances that you manually add to your scaling group are automatically added as the backend servers of the associated CLB instances. The associated CLB instances distribute incoming traffic across instances in your scaling group based on traffic distribution policies and health check policies. This helps improve resource scalability and availability. For more information, see SLB overview.

SLB overview

SLB is a service that can distribute network traffic to a group of backend servers to increase the throughput of applications. You can use SLB to prevent service interruption that is caused by single points of failure (SPOFs) and improve the availability of your applications. For more information, see SLB overview.

SLB provides the following types of load balancers: Application Load Balancer (ALB), Network Load Balancer (NLB), and Classic Load Balancer (CLB).
TypeDescriptionReferences
ALBALB is a Layer 7 load balancing service that provides ultra-high processing capabilities and supports advanced content-based routing features. What is ALB?
NLBNLB is a Layer 4 load balancing service that offers ultra-high performance and connects all things to the Internet. It can also automatically scale on demand. An NLB instance supports up to 100 million concurrent connections, which is ideal for services that require high concurrency. What is NLB?
CLBCLB supports TCP, UDP, HTTP, and HTTPS, and provides high processing capabilities at Layer 4 and basic processing capabilities at Layer 7. After you add servers that are deployed in the same region to a CLB instance, CLB uses virtual IP addresses (VIPs) to combine these servers into a high-performance, highly available server pool. What is CLB?
In the following section, CLB is used as an example to show how to distribute and manage traffic. You must configure a CLB instance, a listener, and a backend server. If you use CLB, you must configure several modules. The modules are described in the following table.
Note If you want to use ALB, you must configure an ALB instance, a listener, and a server group. A listener is the smallest service unit of Alibaba Cloud SLB. A server group is a logical group of backend servers. For more information, see ALB server group overview.
ModuleDescriptionReferences
CLB instanceA CLB instance is an entity that provides load balancing services by distributing network traffic across backend servers.
Note The default weight of an instance in the backend server group of a CLB instance is 50. You can change the weight of the instance based on your business requirements. For more information, see Add an ECS instance to the default server group.
CLB overview
ListenerA listener checks client requests and forwards the requests to backend servers. A listener also performs health checks on backend servers. Listener overview
Backend server groupA backend server group is a logical group of instances that process client requests. You can add multiple instances to the backend server group of a CLB instance. You can also attach multiple vServer groups or primary/secondary server groups to a CLB instance. Backend server overview

Usage notes

This topic describes how to associate or disassociate a CLB instance with or from a scaling group.

After you associate a CLB instance with a scaling group, the following rules apply:
  • If the associated CLB instance is deleted, scaling activities in the scaling group cannot succeed.
  • Auto Scaling regularly checks whether the scaling group has associated CLB instances. If Auto Scaling detects that an associated CLB instance is deleted, Auto Scaling automatically disassociates the CLB instance from the scaling group.
    Important In this case, the disassociated CLB instance cannot be the cause of scaling failures in the scaling group.

Before you associate a CLB instance with your scaling group, take note of the following items:

  • If you set the ForceAttach parameter to false when you call the AttachLoadBalancers API operation, Auto Scaling does not add the existing instances in the scaling group to the backend server group of the associated CLB instance.
  • If you set the ForceAttach parameter to true when you call the AttachLoadBalancers API operation, Auto Scaling adds the existing instances in the scaling group to the backend server group of the associated CLB instance.
  • You can associate up to five CLB instances with your scaling group at the same time by calling the AttachLoadBalancers API operation.
  • If you associated a CLB instance with your scaling group and you did not add the instances in the scaling group to the backend server group of the CLB instance, you can set the ForceAttach parameter to true when you call the AttachLoadBalancers API operation again to add all instances in the scaling group to the backend server group of the CLB instance.
  • Before you associate CLB instances with your scaling group, make sure that the following requirements are met:
    • You have one or more CLB instances in the Running state. For more information, see Create and manage a CLB instance.
    • The scaling group and the CLB instances reside in the same region.
    • At least one listener for which the health check feature is enabled is configured for each CLB instance. For more information, see Listener overview and Configure and manage health checks.
    • If the network type of the CLB instances and the scaling group is virtual private cloud (VPC), the CLB instances and the scaling group must reside in the same VPC.
    • If the network type of the scaling group is VPC, the network type of the CLB instances is classic network, and the backend server groups of the CLB instances contain instances that are created in a VPC, the instances and the scaling group must reside in the same VPC.
      Note In other cases, no limit is applied to the network type when you associate CLB instances with your scaling group.
    • You can associate only a limited number of CLB instances with your scaling group.

Before you disassociate a CLB instance from your scaling group, take note of the following items:

  • If you set the ForceAttach parameter to false when you call the DetachLoadBalancers API operation, Auto Scaling does not remove the existing instances in the scaling group from the backend server group of the dissociated CLB instance.
  • If you set the ForceAttach parameter to true when you call the DetachLoadBalancers API operation, Auto Scaling removes the existing instances in the scaling group from the backend server group of the dissociated CLB instance.
  • You can disassociate up to five CLB instances from your scaling group at the same time by calling the DetachLoadBalancers API operation.
  • Before you disassociate a CLB instance from your scaling group, make sure that the CLB instance no longer distributes traffic across instances in your scaling group to prevent service requests from being lost.

Procedure

You can associate or disassociate CLB instances with or from your scaling group in the Auto Scaling console or by calling API operations. If you call API operations, you do not need to consider business requirements and the required number of CLB instances in advance. The degree of coupling between CLB instances and the scaling group is low. The instances in your scaling group can provide services in a more flexible and stable manner.

API

  • Call the AttachLoadBalancers API operation to associate one or more CLB instances with your scaling group. For more information, see AttachLoadBalancers. You can also call the AttachVServerGroups API operation to add one or more vServer groups to CLB instances. For more information, see AttachVServerGroups.
  • Call the DetachLoadBalancers API operation to disassociate one or more CLB instances from your scaling group. For more information, see DetachLoadBalancers. You can also call the DetachVServerGroups API operation to remove one or more vServer groups from CLB instances. For more information, see DetachVServerGroups.
Note You can also call API operations to associate or disassociate ALB server groups with or from your scaling group. For more information, see AttachAlbServerGroups and DetachAlbServerGroups.

Associate or disassociate CLB instances in the Auto Scaling console

  1. Log on to the Auto Scaling console.
  2. In the left-side navigation pane, click Scaling Groups.
  3. In the top navigation bar, select the region where Auto Scaling is activated.
  4. Go to the page on which you can associate CLB instances with your scaling group.
    • Associate CLB instances with your scaling group when you create the scaling group.

      This step describes how to associate CLB instances with your scaling group. For information about other configurations, see Manage scaling groups.

      1. Click Create.
      2. In the Create Scaling group dialog box, set the Network Type parameter to VPC or Classic Network.
      3. Configure the Associate CLB Instance parameter.
        Note If you set the Network Type parameter to VPC in the Create Scaling Group dialog box, you must configure the VPC parameter before you can configure the Associate ALB Server Group parameter.
        1. Select one or more CLB instances.

          You can associate only a limited number of CLB instances and vServer groups with a scaling group. To view the quota or request a quota increase, go to the Quota Center. If no CLB instances are available, check whether the requirements that are specified in Usage notes are met.

        2. Select one or more backend server groups of the associated CLB instances.
          You can select the default server group and a vServer group. For more information, see Backend server overview.
          Server groupDescription
          Default server groupYou can add instances to the default server group of a listener to receive frontend requests. If you do not specify a vServer group or a primary/secondary server group for the listener, the listener forwards all requests to the instances in the default server group.
          vServer groupIf you want to forward requests to backend servers that are not in the default server group or forward requests based on domain names or URLs, you can select vServer groups.
          When you create a scaling group, you can associate one or more CLB instances with the scaling group, and then specify the weights of instances of the scaling group in the backend server groups of the CLB instances. When you create a scaling configuration in the scaling group, you can also use the SLB Weight parameter to specify the weights of instances that are created from the scaling configuration in the backend server groups of the CLB instances.
          • Scenario 1: When you create a scaling group, you can associate a CLB instance with the scaling group and specify the weights of instances that are added to the CLB backend server group. Figure - Backend server weight
            Important If you set the Instance Configuration Source parameter to Launch Templates, you cannot create a scaling configuration for the scaling group. In this case, you can specify the weights of instances that are added to the CLB backend server group only when you create the scaling group.
          • Scenario 2: When you create a scaling configuration for a scaling group, you can use the SLB Weight parameter to specify weights for instances that are created from the scaling configuration and added as the CLB backend servers. Figure - SLB weight
          The scaling varies based on the method that you use to specify weights of instances as backend servers.
          • If you use methods in Scenario 1 and Scenario 2 to specify instance weights in the CLB backend server group, Auto Scaling triggers scaling activities based on the instance weights that are specified by using the method in Scenario 1 and ignores the instance weights that are specified by using the method in Scenario 2
          • If you specify instance weights by using only the method in Scenario 2, Auto Scaling triggers scaling activities based on the specified instance weights.
          • If you do not specify instance weights when you create a scaling group or scaling configuration, the default instance weight 50 is used when scaling activities are triggered.
      4. Configure other parameters based on your business requirements.
      5. Click OK.
    • Modify the Associate CLB Instance parameter

      This step describes how to modify the configuration of the Associate CLB Instance parameter after you create a scaling group. For information about other configurations, see Modify scaling groups.

      1. Find the scaling group that you want to manage and click Edit in the Actions column.
      2. Select When you associate SLB instances with or disassociate SLB instances from the scaling group, existing ECS instances in the scaling group are added to or removed from the server groups of the SLB instances.
        Note If you associated ALB server groups with your scaling group when you created the scaling group, you can also select When you associate server groups with or disassociate server groups from the scaling group, existing ECS instances in the scaling group are added to or removed from the server groups in the Edit Scaling Group dialog box based on your business requirements. If you select this option, the instances in your scaling group are immediately added to ALB server groups after you associate the ALB server groups with your scaling group. The instances in your scaling group are also immediately removed from ALB server groups after you disassociate the ALB server groups from your scaling group.
        • If you select this option, the instances in your scaling group are immediately added to the backend server groups of CLB instances after you associate the CLB instances with your scaling group. The instances in your scaling group are also immediately removed from the backend server groups of CLB instances after you disassociate the CLB instances from your scaling group.
        • If you do not select this option, the configurations of the backend server groups of CLB instances remain unchanged after you associate the CLB instances with or disassociate the CLB instances from your scaling group.
      3. Select Asynchronously unmount or mount default server groups based on your business requirements.
        • If you select this option, a scaling activity occurs each time you mount or unmount the default server group. If you mount and unmount the default server group at the same time, this setting does not take effect.
        • If you do not select this option, no scaling activity occurs each time you mount or unmount the default server group.
      4. Optional: Change the weights of instances that are added as the backend servers of the associated CLB instance based on your business requirements.

        If you associated a CLB instance with your scaling group when you created the scaling group and you did not specify instance weights, you can specify instance weights after you created the scaling group based on your business requirements. For more information about instance weights, see Step 5.

      5. Modify other parameters based on your business requirements.
      6. Click OK.