You can call the AttachDBInstances API operation to associate ApsaraDB RDS instances with a scaling group, or call the DetachDBInstances API operation to disassociate ApsaraDB RDS instances from a scaling group. You can call API operations to change the number of the ApsaraDB RDS instances that are associated with a scaling group based on business requirements. This way, you can manage the association between your scaling group and ApsaraDB RDS instances in various business scenarios in a flexible manner. This topic describes the methods that you can use to associate ApsaraDB RDS instances with a scaling group or disassociate ApsaraDB RDS instances from a scaling group.

Background information

Elastic Compute Service (ECS) instances in a scaling group may be automatically released. We recommend that you store application data on ApsaraDB instances such as ApsaraDB RDS instances, ApsaraDB for MongoDB instances, and PolarDB instances. For information about how to associate ECS instances in a scaling group with ApsaraDB instances or disassociate ECS instances in a scaling group from ApsaraDB instances, see Associate ECS instances in a scaling group with ApsaraDB instances.

  • ApsaraDB RDS is a stable, reliable, and scalable online database service of Alibaba Cloud. ApsaraDB RDS supports the MySQL, SQL Server, PostgreSQL, and MariaDB TX database engines. ApsaraDB RDS provides a portfolio of solutions for disaster recovery, backup, restoration, monitoring, and migration to facilitate database O&M. The IP addresses of the instances in a scaling group can be automatically added to the whitelists that manage access to the ApsaraDB RDS instances with which the scaling group is associated. For more information about the ApsaraDB RDS instances, see What is ApsaraDB RDS?
  • After you associate a scaling group with a specified number of ApsaraDB RDS instances, the private IP addresses of ECS instances in the scaling group can be automatically added to the whitelists that manage access to the ApsaraDB RDS instances with which the scaling group is associated. This way, you can establish a connection between the ECS instances and the ApsaraDB RDS instances over an internal network.

Precautions

You can call the AttachDBInstances and DetachDBInstances API operations to change the number of ApsaraDB instances that are associated with a scaling group based on business requirements.

Before you call the AttachDBInstances API operation to increase the number of ApsaraDB RDS instances that are associated with a scaling group, take note of the following items:

  • If you set the request parameter ForceAttach to false when you call the AttachDBInstances API operation, the system does not add the private IP addresses of ECS instances in the scaling group to the whitelists that manage access to the ApsaraDB RDS instances with which the scaling group is associated.
  • If you set the request parameter ForceAttach to true when you call the AttachDBInstances API operation, the system adds the private IP addresses of ECS instances in the scaling group to the whitelists that manage access to the ApsaraDB RDS instances with which the scaling group is associated.
  • You can associate up to five ApsaraDB RDS instances with a scaling group at a time by calling the AttachDBInstances API operation.
  • If an ApsaraDB RDS instance is associated with a scaling group but the private IP addresses of the ECS instances in the scaling group are not added to the whitelist that manages access to the ApsaraDB RDS instance, the number of ApsaraDB RDS instances that are associated with the scaling group remains unchanged after you reassociate the ApsaraDB RDS instance with the scaling group. The system attempts to add the private IP addresses of all ECS instances in the scaling group to the whitelist that manages access to the ApsaraDB RDS instance.
  • You can associate only the ApsaraDB RDS instances that meet the following conditions with a scaling group:
    • ApsaraDB RDS instances are created.
    • ApsaraDB RDS instances are in the Running state.
    • The default IP address whitelist that manages access to an ApsaraDB RDS instance can contain up to 1,000 IP addresses.

Before you call the DetachDBInstances API operation to decrease the number of ApsaraDB RDS instances that are associated with a scaling group, take note of the following items:

  • If you set the request parameter ForceAttach to false when you call the DetachDBInstances API operation, the system does not remove the private IP addresses of ECS instances in the scaling group from the whitelists that manage access to the ApsaraDB RDS instances from which the scaling group is disassociated.
  • If you set the request parameter ForceAttach to true when you call the DetachDBInstances API operation, the system removes the private IP addresses of ECS instances in the scaling group from the whitelists that manage access to the ApsaraDB RDS instances from which the scaling group is disassociated.
  • You can disassociate up to five ApsaraDB RDS instances from a scaling group at a time by calling the DetachDBInstances API operation.
  • You cannot disassociate an ApsaraDB RDS instance from a scaling group twice.

Procedure

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

Associate ApsaraDB RDS instances with your scaling group or disassociate ApsaraDB RDS instances from a scaling group by calling API operations

  • Call the AttachDBInstances API operation to associate one or more ApsaraDB RDS instances with a scaling group. For more information, see AttachDBInstances.
  • Call the DetachDBInstances API operation to disassociate one or more ApsaraDB RDS instances from a scaling group. For more information, see DetachDBInstances.

Associate ApsaraDB RDS instances with a scaling group or disassociate ApsaraDB RDS instances from a scaling group by using the Auto Scaling console

You can use the Auto Scaling console to associate ApsaraDB RDS instances with a scaling group or disassociate ApsaraDB RDS instances from a scaling group. For more information, see Create a scaling group and Modify scaling groups. Take note of the following items:

  • The system automatically adds the private IP addresses of ECS instances in the scaling group to the whitelists that manage access to the ApsaraDB RDS instances with which the scaling group is associated.
  • The system automatically removes the private IP addresses of ECS instances in the scaling group from the whitelists that manage access to the ApsaraDB RDS instances from which the scaling group is disassociated.