Manual scaling for Amazon EC2 Auto Scaling
You can manually adjust the number of EC2 instances in your Auto Scaling group at any time. This process of changing the instance count manually is referred to as manual scaling. Manual scaling is an alternative to auto scaling, especially if you want to make one-time capacity changes.
After you manually scale your group, Amazon EC2 Auto Scaling resumes normal auto scaling activities based on the scaling policies and scheduled actions that you defined. For groups with default instance warmup enabled, any new instances go through a warmup period before they start contributing to the metrics used for auto scaling. This warmup period assists in stabilizing the group at the new capacity. For more information, see Set the default instance warmup for an Auto Scaling group.
Sometimes, you may want to temporarily disable scaling policies and scheduled actions before manually scaling a group. Doing so prevents conflicts from arising between manual scaling actions and automated scaling activities. For more information, see Turn off scaling activities.
Contents
Change the desired capacity of an existing Auto Scaling group
When you change the desired capacity of your Auto Scaling group, Amazon EC2 Auto Scaling manages the process of launching and terminating instances to reach the new desired size.
Terminate instances in your Auto Scaling group (AWS CLI)
There are times when you might want to manually scale in your Auto Scaling group but want
to terminate specific instances. You can terminate one or more instances by using
the terminate-instance-in-auto-scaling-group
To terminate a single instance, specify the instance ID with the
--instance-id option and the
--should-decrement-desired-capacity option as shown in the
following example.
aws autoscaling terminate-instance-in-auto-scaling-group \ --instance-idi-026e4c9f62c3e448c--should-decrement-desired-capacity
The following is example output, which provides details about the scaling activity.
{
"Activities": [
{
"ActivityId": "b8d62b03-10d8-9df4-7377-e464ab6bd0cb",
"AutoScalingGroupName": "my-asg",
"Description": "Terminating EC2 instance: i-026e4c9f62c3e448c",
"Cause": "At 2023-09-23T06:39:59Z instance i-026e4c9f62c3e448c was taken out of service in response to a user request, shrinking the capacity from 1 to 0.",
"StartTime": "2023-09-23T06:39:59.015000+00:00",
"StatusCode": "InProgress",
"Progress": 0,
"Details": "{\"Subnet ID\":\"subnet-6194ea3b\",\"Availability Zone\":\"us-west-2c\"}"
}
]
}
To terminate multiple instances in a single request, specify the instance IDs
with the --instance-ids option and specify the group with the
--auto-scaling-group-name option. You can terminate up to 100
instances per request. The following example terminates three instances.
aws autoscaling terminate-instance-in-auto-scaling-group \ --instance-idsi-061c63c5eb45f0416i-0b11f4eb2b3e987dfi-09b21afe8ef4dab66\ --auto-scaling-group-namemy-asg\ --should-decrement-desired-capacity
The following is example output.
{
"Activities": [
{
"ActivityId": "a1b2c3d4-e5f6-7890-abcd-111111111111",
"AutoScalingGroupName": "my-asg",
"Description": "Terminating EC2 instance: i-061c63c5eb45f0416",
"Cause": "At 2024-01-15T10:30:00Z instance i-061c63c5eb45f0416 was taken out of service in response to a user request, shrinking the capacity from 5 to 4.",
"StartTime": "2024-01-15T10:30:00.000000+00:00",
"StatusCode": "InProgress",
"Progress": 0,
"Details": "{\"Subnet ID\":\"subnet-6194ea3b\",\"Availability Zone\":\"us-west-2a\"}"
},
{
"ActivityId": "a1b2c3d4-e5f6-7890-abcd-222222222222",
"AutoScalingGroupName": "my-asg",
"Description": "Terminating EC2 instance: i-0b11f4eb2b3e987df",
"Cause": "At 2024-01-15T10:30:00Z instance i-0b11f4eb2b3e987df was taken out of service in response to a user request, shrinking the capacity from 4 to 3.",
"StartTime": "2024-01-15T10:30:00.000000+00:00",
"StatusCode": "InProgress",
"Progress": 0,
"Details": "{\"Subnet ID\":\"subnet-6194ea3b\",\"Availability Zone\":\"us-west-2b\"}"
},
{
"ActivityId": "a1b2c3d4-e5f6-7890-abcd-333333333333",
"AutoScalingGroupName": "my-asg",
"Description": "Terminating EC2 instance: i-09b21afe8ef4dab66",
"Cause": "At 2024-01-15T10:30:00Z instance i-09b21afe8ef4dab66 was taken out of service in response to a user request, shrinking the capacity from 3 to 2.",
"StartTime": "2024-01-15T10:30:00.000000+00:00",
"StatusCode": "InProgress",
"Progress": 0,
"Details": "{\"Subnet ID\":\"subnet-6194ea3b\",\"Availability Zone\":\"us-west-2c\"}"
}
]
}
When you use batch termination, note the following behaviors:
-
You can specify up to 100 instances per request.
-
All instances must belong to the Auto Scaling group that you specify with
--auto-scaling-group-name. -
If any instance fails validation, the entire request is rejected and no instances are terminated.
-
You cannot specify both
--instance-idand--instance-idsin the same request. -
Lifecycle hooks fire for each instance in the batch.
This option is not available in the console. However, you can use the Instances page of the Amazon EC2 console to terminate an instance in your Auto Scaling group. When you do so, Amazon EC2 Auto Scaling detects that the instance is no longer running and replaces it automatically as part of the health check process. It takes a minute or two after you terminate the instance before a new instance launches. For information about how to terminate an instance, see Terminate an instance in the Amazon EC2 User Guide.
If you terminate instances in your group and that causes uneven distribution
across Availability Zones, Amazon EC2 Auto Scaling rebalances the group to re-establish an even
distribution unless you suspend the AZRebalance process. For more
information, see Suspend and resume Amazon EC2 Auto Scaling processes.