All Products
Search
Document Center

Auto Scaling:Attach or detach ApsaraDB RDS instances to or from scaling groups

Last Updated:Apr 08, 2024

Auto Scaling provides the AttachDBInstances and DetachDBInstances operations that you can call to attach or detach ApsaraDB RDS instances to or from scaling groups. This allows you to flexibly adjust the number of ApsaraDB RDS instances that are attached to your scaling group based on your business requirements. This topic describes how to attach or detach ApsaraDB RDS instances to or from scaling groups.

Background information

  • You can attach ApsaraDB RDS instances to scaling groups of both the Elastic Compute Service (ECS) type and the Elastic Container Instance type. This topic describes the usage notes and steps for attaching or detaching ApsaraDB RDS instances to or from scaling groups of the ECS type.

  • ECS instances or elastic container instances in a scaling group may be automatically released. We recommend that you store your application data on ApsaraDB instances, such as ApsaraDB RDS instances, ApsaraDB for MongoDB (MongoDB) instances, and PolarDB instances. For information about how to attach ApsaraDB RDS instances to ECS instances in a scaling group, see Associate ECS instances in a scaling group with ApsaraDB instances.

  • Before you proceed with your operation, take note of the following items:

    • ApsaraDB RDS is an online database service developed by Alibaba Cloud. It is stable, reliable, and scalable and supports database engines such as MySQL, SQL Server, PostgreSQL, and MariaDB. ApsaraDB RDS provides disaster recovery, backup, restoration, monitoring, and migration capabilities, thereby reducing the burden of database O&M. After the attachment of an ApsaraDB RDS instance to a scaling group, the private IP addresses of the instances in the scaling group are added to the IP address whitelist of the ApsaraDB RDS instance. This allows access from the instances in the scaling group to the ApsaraDB RDS instance. For more information, see What is ApsaraDB RDS?

    • The AttachDBInstances and DetachDBInstances operations allow you to flexibly adjust the number of ApsaraDB RDS instances attached to your scaling group. The operations also enable the automatic addition or removal of the private IP addresses of the instances in your scaling group to or from the IP address whitelists of the attached ApsaraDB RDS instances. If you want to implement internal communication between instances in your scaling group and the attached ApsaraDB RDS instances, the private IP addresses of the instances in your scaling group must be on the IP address whitelists of the attached ApsaraDB RDS instances.

Usage notes

You can call the AttachDBInstances and DetachDBInstances API operations to adjust the number of ApsaraDB RDS instances that are attached to your scaling group based on your business requirements. In this topic, only usage notes related to the API operations are provided.

  • After you attach an ApsaraDB RDS instance to your scaling group, take note of the following items:

    • If an attached ApsaraDB RDS instance is deleted or does not exist, scaling activities in the scaling group fail.

    • Auto Scaling regularly checks whether the attached ApsaraDB RDS instance of your scaling group exists. If Auto Scaling detects that the attached ApsaraDB RDS is deleted or does not exist, it automatically detaches the ApsaraDB RDS instance from your scaling group.

      Important

      After the automatic detachment of the ApsaraDB RDS instance from your scaling group, no scaling failures caused by the ApsaraDB RDS instance occur in your scaling group.

  • Before you attach ApsaraDB RDS instances to or from your scaling group, you must also take note of the following items:

    Attach ApsaraDB RDS instances to a scaling group

    • If you set the ForceAttach request parameter to false when you call the AttachDBInstances API operation, Auto Scaling does not add the private IP addresses of existing ECS instances in the scaling group to the IP address whitelists of the ApsaraDB RDS instances that you want to attach.

    • If you set the ForceAttach request parameter to true when you call the AttachDBInstances API operation, Auto Scaling adds the private IP addresses of existing ECS instances in the scaling group to the IP address whitelists of the ApsaraDB RDS instances that you want to attach.

    • You can attach up to five ApsaraDB RDS instances to a scaling group in each call.

    • If your scaling group has an attached ApsaraDB RDS instance and you want to attach the instance to your scaling group again, the number of the ApsaraDB RDS instances attached to your scaling group remains unchanged after the attachment but Auto Scaling adds the private IP addresses of the ECS instances in your scaling group to the IP address whitelist of the ApsaraDB RDS instance.

    • The ApsaraDB RDS instances that you can attach to your scaling group must meet the following requirements:

      • The ApsaraDB RDS instances are created by using your Alibaba Cloud account and not deleted.

      • The ApsaraDB RDS instances are in the Running state.

      • The default IP address whitelist of each ApsaraDB RDS instance contains no more than 1000 IP addresses.

    Detach ApsaraDB RDS instances from a scaling group

    • If you set the ForceAttach request parameter to false when you call the DetachDBInstances API operation, Auto Scaling does not remove the private IP addresses of ECS instances in the scaling group from the IP address whitelists of the ApsaraDB RDS instances that you want to detach.

    • If you set the ForceAttach request parameter to true when you call the DetachDBInstances API operation, Auto Scaling removes the private IP addresses of ECS instances in the scaling group from the IP address whitelists of the ApsaraDB RDS instances that you want to detach.

    • You can detach up to five ApsaraDB RDS instances from a scaling group in each call.

    • You cannot attach and detach an ApsaraDB RDS instance at the same time. You can detach an ApsaraDB RDS instance from a scaling group only after the attachment of the instance to the scaling group is complete.

Procedure

You can attach or detach ApsaraDB RDS instances to or from a scaling group by calling API operations or using the Auto Scaling console. We recommend that you call API operations. This method decouples ApsaraDB RDS instances from scaling groups, which saves you the trouble of estimating the required number of ApsaraDB RDS instances based on your business demands in advance. API operations improve the service capability of scaling groups more flexibly.

API operations

  • Call the AttachDBInstances API operation to attach one or more ApsaraDB RDS instances to a scaling group. For more information, see AttachDBInstances.

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

Auto Scaling console

Attach or detach ApsaraDB RDS instances to or from a scaling group. For more information, see Manage scaling groups and Modify scaling groups. The following rules apply after each attachment or detachment is complete:

  • Auto Scaling automatically adds the private IP addresses of existing ECS instances in the scaling group to the IP address whitelists of the attached ApsaraDB RDS instances.

  • Auto Scaling automatically removes the private IP addresses of existing ECS instances in the scaling group from the IP address whitelists of the detached ApsaraDB RDS instances.

References

You can also attach load balancers to your scaling group to distribute incoming traffic across the instances in the scaling group. This improves the performance of your scaling group. For more information, see Attach or detach SLB instances to or from scaling groups.