This topic describes how to configure naming rules to generate unique sequential Elastic Compute Service (ECS) instance names or hostnames during scale-outs. You can use the names to manage ECS instances in an efficient manner.
Background information
Auto Scaling can execute scaling rules to create one or more ECS instances at the same time or in different batches. You can configure naming rules for ECS instances that are created during scale-outs in launch templates or scaling configurations.
The method that is used to configure naming rules varies based on the scenarios. In this topic, the method that is suitable for Scenario 1 is used to show how to configure naming rules.
Scenario
Method
References
Scenario 1: All ECS instances that are created in a scaling group during scale-outs must have unique sequential names or hostnames.
Configure the naming format based on the naming rules in scaling configurations. In this scenario, you cannot use a launch template to configure the naming format for ECS instances.
ImportantECS instance names or hostnames are sequentially generated, but not necessarily generated in a consecutive manner. For example, the hostnames of the ECS instances that are created in a scaling group during a scale-out are ess-node-0999, ess-node-1000, and ess-node-1002. The ess-node-1001 ECS instance does not start as expected. Therefore, the instance is considered unhealthy and removed. As a result, Auto Scaling creates another ECS instance named ess-node-1002.
Scenario 2: The names or hostnames of the ECS instances that are created in a scaling group during the same scale-out must be sequential and unique. The names or hostnames can be used by ECS instances that are created in another scale-out in the scaling group.
Configure the naming format for ECS instances based on the specified ranking order.
Batch configure sequential names or hostnames for multiple instances
Scenario 3: No requirements are imposed on the names or hostnames of ECS instances that are created during scale-outs in a scaling group.
Configure a custom name or hostname for the ECS instances.
For example, you can specify "hostname" as the hostname for all ECS instances that are created during scale-outs.
N/A
Method 1: Configure the naming rule for ECS instances in the Auto Scaling console
Create a scaling group.
For more information, see Create scaling groups.
Create and enable a scaling configuration.
For more information, see Create a scaling configuration of the ECS type. In the Advanced Settings section of the Create Scaling Configuration page, configure the Instance Name and Host Name parameters to specify the naming format.
In this example, the Instance Name parameter is set to
ess-node-(AUTO_INCREMENT)[0,3]
and the Host Name parameter is set toess-node-(AUTO_INCREMENT)[0,3]-ecshost
.NoteIn this example, the ECS instance names or hostnames are sequentially increased. For more information, see (Recommended) Increment by fixed value. If you want to dynamically generate sequential instance names or hostnames, see Dynamic sorting by extended sequential value.
Enable the scaling group.
For more information, see Enable a scaling group.
Create and execute a scaling rule.
Create a scaling rule.
For more information, see Create scaling rules.
In this example, a simple scaling rule is created. Auto Scaling creates three ECS instances when the rule is executed.
Execute the scaling rule.
For more information, see Execute scaling rules.
After the scale-out is complete, three ECS instances that have the following instance names and hostnames are added to the scaling group:
Instance names: ess-node-000, ess-node-001, and ess-node-002
Hostnames: ess-node-000-ecshost, ess-node-001-ecshost, and ess-node-002-ecshost
Method 2: Configure the naming rule for ECS instances by calling API operations
Call the CreateScalingGroup API operation to create a scaling group.
For more information, see CreateScalingGroup.
Call the CreateScalingConfiguration API operation to create a scaling configuration.
For more information, see CreateScalingConfiguration. In the Request parameters section, configure the InstanceName and HostName parameters.
In this example, the InstanceName parameter is set to
ess-node-(AUTO_INCREMENT)[0,3]
and the HostName parameter is set toess-node-(AUTO_INCREMENT)[0,3]-ecshost
.NoteIn this example, the ECS instance names or hostnames are sequentially increased. For more information, see (Recommended) Increment by fixed value. If you want to dynamically generate sequential instance names or hostnames, see Dynamic sorting by extended sequential value.
Call the EnableScalingGroup API operation to enable the scaling group.
For more information, see EnableScalingGroup.
Create and execute a scaling rule.
Call the CreateScalingRule API operation to create a scaling rule.
For more information, see CreateScalingRule.
In this example, a simple scaling rule is created. Auto Scaling creates three ECS instances when the rule is executed.
Call the ExecuteScalingRule API operation to execute the scaling rule.
For more information, see ExecuteScalingRule.
After the scale-out is complete, three ECS instances that have the following instance names and hostnames are added to the scaling group:
Instance names: ess-node-000, ess-node-001, and ess-node-002
Hostnames: ess-node-000-ecshost, ess-node-001-ecshost, and ess-node-002-ecshost
(Recommended) Increment by fixed value
Instance names and hostnames must be in the following format: name_prefix(AUTO_INCREMENT)[begin_number,bits]name_suffix.
The naming rules for instance names and hostnames follow the same logic. The following table describes only the format of hostnames.
Field | Required | Description | Example |
name_prefix | Yes | The prefix of the hostname. | ess-node- |
(AUTO_INCREMENT) | Yes | The fixed value that specifies the sorting mode. | (AUTO_INCREMENT) |
[begin_number,bits] | Yes | The sequential values of hostnames. After you configure this parameter, the sequential values of hostnames are increased by the specified fixed value. Important The [begin_number,bits] field cannot contain spaces. By default, the sequential names of hostnames are increased based on a fixed value. If Auto Scaling fails to start an ECS instance in a scaling group during a scale-out, Auto Scaling removes the ECS instance from the scaling group and creates another ECS instance. In this case, the hostnames of the ECS instances in the scaling group may have an intermittent increasing pattern.
Note We recommend that you set the bits field to 3 or larger. Otherwise, the upper limit of the sequential values may be reached in a short period of time. If Auto Scaling needs to create more ECS instances after the upper limit is reached, an error is reported and the scale-out is stopped. In this case, you must reconfigure the rules for generating hostnames. | [0,6] |
name_suffix | No | The suffix of the hostname. | -ecshost |
Example | Existing hostname with the maximum sequential value | Hostnames of three added ECS instances | Description |
ess-node-(AUTO_INCREMENT)[0,3]-ecshost | N/A | ess-node-000-ecshost, ess-node-001-ecshost, and ess-node-002-ecshost | The number of digits in all sequential values is the bits value. The first time Auto Scaling creates instances in a scaling group, the sequential value starts from the begin_number value and sequentially increases based on the number of created instances. |
| N/A | ess-node-000000-ecshost, ess-node-000001-ecshost, and ess-node-000002-ecshost | If you do not configure the begin_number or bits field, the default value of the begin_number field is 0 and the default value of the bits field is 6. |
ess-node-(AUTO_INCREMENT)[99,1]-ecshost | ess-node-000099-ecshost | ess-node-000100-ecshost, ess-node-000101-ecshost, and ess-node-000102-ecshost |
|
ess-node-(AUTO_INCREMENT)[0,2]-ecshost | ess-node-99-ecshost | An error is reported and the scale-out is stopped. |
|
ess-node-(AUTO_INCREMENT)[0,4] | ess-node-0998-ecshost | ess-node-0999, ess-node-1000, and ess-node-1002 |
|
Dynamic sorting by extended sequential value
Instance names and hostnames must be in the following format: name_prefix(AUTO_INCREMENT)[begin_number,bits]name_suffix.
The naming rules for instance names and hostnames follow the same logic. The following table describes only the format of hostnames.
Field | Required | Description | Example |
name_prefix | Yes | The prefix of the hostname. | ess-node- |
(ess_extend_begin,ess_extend_bits) | Yes | The extended sequential value of the hostname. When the base sequential value of existing hostnames in a scaling group is equal to the maximum sequential value, one value is added to the extended sequential value. Then, the base sequential value increases from 0 again until the upper limit is reached.
Important If Auto Scaling needs to create more ECS instances when the upper limits of the base and extended sequential values are reached, an error is returned and the scale-out is stopped. In this case, you must reconfigure the rules for generating hostnames. The (ess_extend_begin,ess_extend_bits) field cannot contain spaces. If the number of digits in the specified ess_extend_begin value is greater than the bits value, the bits field is automatically set to 3. | (0,3) |
[begin_number,bits] | Yes | The base sequential value of the hostname. After you configure this field, the base sequential values of hostnames are increased to the maximum value. Then, one value is added to the extended sequential value and the base sequential value increases from 0 again until the upper limit is reached. Important By default, hostnames are sequentially increased. If Auto Scaling fails to start an ECS instance in a scaling group during a scale-out, Auto Scaling removes the ECS instance from the scaling group and creates another ECS instance. In this case, the hostnames of the ECS instances in the scaling group may have an intermittent increasing pattern.
Important
The [begin_number,bits] field cannot contain spaces. If the number of digits in the specified begin_number value is greater than the bits value, the bits field is automatically set to 6. | [0,6] |
name_suffix | No | The suffix of the hostname. | -ecshost |
Example | Existing hostname with the maximum sequential value | Hostnames of three added ECS instances | Description |
ess-node-(0,3)[0,3]-ecshost | N/A | ess-node-000000-ecshost, ess-node-000001-ecshost, and ess-node-000002-ecshost | The first time Auto Scaling creates instances in a scaling group, the sequential values of hostnames are specified based on the following rules:
|
| N/A | ess-node-000000000-ecshost, ess-node-000000001-ecshost, and ess-node-000000002-ecshost |
|
ess-node-(0,1)[0,1]-ecshost | ess-node-08-ecshost | ess-node-10-ecshost, ess-node-11-ecshost, and ess-node-12-ecshost |
|
ess-node-(0,1)[0,1]-ecshost | ess-node-Z9-ecshost | An error is reported and the scale-out is stopped. |
|
ess-node-(0,1)[0,3] | ess-node-0099-ecshost | ess-node-0100, ess-node-0101, and ess-node-0103 |
|
ess-node-(0,1)[99,1]-ecshost | ess-node-0000099-ecshost | ess-node-0000100-ecshost, ess-node-0000101-ecshost, and ess-node-0000102-ecshost |
|