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

Background information

In this topic, Classic Load Balancer (CLB) instances are used. CLB is previously known as SLB. 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 then 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.

Alibaba Cloud SLB provides the following types of load balancers: CLB and Application Load Balancer (ALB).

  • CLB supports TCP, UDP, HTTP, and HTTPS. CLB provides robust processing capabilities at Layer 4 and basic processing capabilities at Layer 7. CLB allows multiple instances in the same region to share service loads by using the IP address of a CLB instance. These instances are used as resources for a high-performance and high-availability application service pool. For more information, see What is CLB?
  • ALB provides ultra-high processing performance at Layer 7 and advanced content-based routing features. For more information, see What is Application Load Balancer (ALB)?
In the following section, CLB is used as an example to describe how to distribute and manage traffic. You must configure a CLB instance, a listener, and a backend server.
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. A server group is a logical group that contains multiple backend servers. For more information, see Server groups.
  • A CLB instance is a running service entity that receives traffic and forwards the traffic to backend servers. For more information, see CLB overview.
  • A listener checks client requests and forwards the requests to backend servers. A listener performs health checks on backend servers. For more information, see Listener overview.
  • A backend server group is a group of instances that receive requests from the frontend. You can add instances to a server pool one by one, or add multiple instances to a vServer group or a primary/secondary server group at a time. For more information, see Backend server overview.
    Note The default weight of an instance in the backend server group of a CLB instance is 50. You can modify the weight of the instance based on your business requirements. For more information, see Add and manage a default backend server.

Precautions

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

  • If you set the request parameter ForceAttach to false when you call the AttachLoadBalancers API operation, the system does not add the existing instances in the scaling group to the backend server group of the associated CLB instance.
  • If you set the request parameter ForceAttach to true when you call the AttachLoadBalancers API operation, the system 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 a time by calling the AttachLoadBalancers API operation.
  • If you associated a CLB instance with your scaling group but you did not add the instances in the scaling group to the backend server group of the CLB instance, you can set the request parameter ForceAttach to true when you call the AttachLoadBalancers API operation.
  • Before you associate CLB instances with your scaling group, make sure that the following requirements are met:
    • You have one or more CLB instances that are 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 is configured for each CLB instance, and the health check feature is enabled for each CLB instance. For more information, see Listener overview and Configure health check.
    • 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 request parameter ForceAttach to false when you call the DetachLoadBalancers API operation, the system does not remove instances in the scaling group from the backend server group of the dissociated CLB instance.
  • If you set the request parameter ForceAttach to true when you call the DetachLoadBalancers API operation, the system removes 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 a 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 CLB instances with your scaling group or disassociate CLB instances from your scaling group by using the Auto Scaling console or calling API operations. If you call API operations, you do not need to consider service requirements and the required number of CLB instances in advance. The degree of coupling between CLB instances and the scaling group is low. This way, the instances in your scaling group can provide services in a more flexible and stable manner.

Associate or disassociate CLB instances by calling API operations

  • 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 ALB server groups with your scaling group or disassociate ALB server groups from your scaling group. For more information, see AttachAlbServerGroups and DetachAlbServerGroups.

Associate or disassociate CLB instances by using 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 a region.
  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 Create a scaling group.

      1. Click Create.
      2. In the Create Scaling group dialog box, set Network Type to VPC or Classic Network.
      3. Set the Associate CLB Instance parameter.
        Note If you set Network Type to VPC in the Create Scaling Group dialog box, you must set the VPC parameter before you can set 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 Precautions are met.

        2. Select one or more backend server groups of the associated CLB instances.

          You can select a default server group and a vServer group. For more information, see Backend server overview.

          • The default server group is a group of instances that receive requests from the frontend. If you do not specify a vServer group or primary/secondary server group for the listener, the listener forwards all requests to instances in the default server group.
          • If 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 use a vServer group.
      4. Configure other parameters based on your business requirements.
      5. Click OK.
    • Modify the configuration of the Associate CLB Instance parameter after you create a scaling group.

      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 based on your business requirements.
        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 the scaling group, or the instances in your scaling group are 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, or the instances in your scaling group are 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 your scaling group 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 default server groups. This setting takes effect only when you mount or unmount default server groups. This setting does not take effect if you mount default server groups and unmount default server groups at the same time.
        • If you do not select this option, no scaling activity occurs each time you mount or unmount default server groups.
      4. Modify other parameter configurations based on your business requirements.
      5. Click OK.