This topic describes how to create a scaling configuration for a scaling group and specify an ECS instance template for automatic scaling.

Background information

The scaling configuration creation process is similar to that of an ECS instance. However, as a scaling configuration is a template for ECS instance to be used during automatic scaling, it has several key differences such as supporting different instance types and not allowing you to configure certain parameters (such as region or resource group). See the actual interface of the Auto Scaling console when using this document. Brief descriptions of each parameter are also displayed on the interface. For more information about parameter descriptions, seeCreate an instance by using the wizard .

Preparations

Procedure in the Auto Scaling console

  1. Log on to theAuto Scaling console. In theActions column corresponding to a scaling group, clickManage.
  2. In the left-side navigation pane, clickInstance Configuration Source. On the tab page that appears, clickCreate Scaling Configuration.
  3. On theBasic Configurations page, configure the billing method, instance, image, storage, public network bandwidth, and security group. ClickNext: System Configurations.
    Note In the basic configurations:
    • Billing method: Only thePay-As-You-Go andPreemptible instances methods are supported.
    • Instance: Multiple instance types are supported. When the instance inventory of a specific type is insufficient, the instances of the alternate types will be used to improve the scaling success rate.
  4. On theSystem Configurations page, configure the logon credential, tag (optional), instance name (optional), and advanced options (optional). ClickNext: Preview.
    Note Advanced options are available only for scaling configurations in a VPC-type scaling group. The options include RAM role and custom data of instances.
  5. On thePreview page, check your configurations, enter the scaling configuration name, and clickCreate.
  6. In theActivated dialog box that appears, you can click Enable Configuration, click Create More tocreate another scaling configuration, or close the dialog box.

API example

A scaling configuration is a template used by a scaling group to elastically create ECS instances. Before you use an API to create a scaling configuration, make sure that the request contains the ID of a scaling group, the ID of a security group to which ECS instances will belong, the ID of an ECS instance image, and the type of the ECS instances to be used.

We recommend that you choose anAlibaba Cloud SDK based on your programming language. Java SDK example:

import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
/*
pom.xml
<dependency> 
  <groupId>com.aliyun</groupId> 
  <artifactId>aliyun-java-sdk-core</artifactId> 
  <version>4.0.3</version>
</dependency> 
*/
public class CommonRpc {
    public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>");
        IAcsClient client = new DefaultAcsClient(profile);

        CommonRequest request = new CommonRequest();
        request.setMethod(MethodType.POST);
        request.setDomain("ess.aliyuncs.com");
        request.setVersion("2014-08-28");
        request.setAction("CreateScalingConfiguration");
        request.putQueryParameter("ScalingGroupId", "asg-bp1a4xzjr1ypd6016356");
        request.putQueryParameter("SecurityGroupId", "sg-bp147qpndp7iyj08l74h");
        request.putQueryParameter("ImageId", "centos6u5_64_20G_aliaegis_20140703.vhd");
        request.putQueryParameter("InstanceType", "ecs.t1.xsmall");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}

After you have initiated a call through the Java SDK or other methods, the request body is similar as follows:

https://ess.aliyuncs.com/?Action=CreateScalingConfiguration
&ImageId=centos6u5_64_20G_aliaegis_20140703.vhd 
&InstanceType=ecs.t1.xsmall 
&ScalingGroupId=asg-bp1a4xzjr1ypd6016356
&SecurityGroupId=sg-bp147qpndp7iyj08l74h
&Version=2014-08-28 
In the request,
  • centos6u5_64_20G_aliaegis_20140703.vhd indicates the ID of the ECS instance image.
  • ecs.t1.xsmall indicates the type of the ECS instances.
  • AG6CQdPU8OKdwLjgZcJ2ea indicates the ID of the scaling group.
  • sg-280ih3w indicates the ID of the scaling group to which the ECS instances will belong.
  • 2014-08-28 indicates the version of the API.

You can also customize attributes such as different instance types and ECS instance disks. For more information about the API, seeCreateScalingConfiguration.