Manual scaling for Amazon EC2 Auto Scaling - Amazon EC2 Auto Scaling

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.

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.

Console
To change the size of your Auto Scaling group
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/, and choose Auto Scaling Groups from the navigation pane.

  2. Select the check box next to your Auto Scaling group.

    A split pane displays at the bottom of the page.

  3. On the Details tab, choose Group details, Edit.

  4. For Desired capacity, increase or decrease the desired capacity. For example, to increase the size of the group by one, if the current value is 1, enter 2.

    If your new value for Desired capacity is greater than Min desired capacity and Max desired capacity, the Max desired capacity is automatically increased to the new desired capacity value.

  5. When you are finished, choose Update.

Verify that the group size that you specified resulted in the same amount of instances being launched. For example, if you increased the size of the group by one, verify that your Auto Scaling group has launched one additional instance.

To verify that the size of your Auto Scaling group has changed
  1. On the Activity tab, in Activity history, you can view the progress of activities that are associated with the Auto Scaling group. The Status column shows the current status of your instance. While your instance is launching, the status column shows Not yet in service. The status changes to Successful after the instance is launched. You can also use the refresh icon to see the current status of your instance. For more information, see Verify a scaling activity for an Auto Scaling group.

  2. On the Instance management tab, in Instances, you can view the status of the instance. It takes a short time for an instance to launch.

    • The Lifecycle column shows the state of your instance. Initially, your instance is in the Pending state. After an instance is ready to receive traffic, its state is InService.

    • The Health status column shows the result of the Amazon EC2 Auto Scaling health checks on your instance.

AWS CLI

The following example assumes that you've created an Auto Scaling group with a minimum size of 1 and a maximum size of 5. Therefore, the group currently has one running instance.

To change the size of your Auto Scaling group

Use the set-desired-capacity command to change the size of your Auto Scaling group, as shown in the following example.

aws autoscaling set-desired-capacity --auto-scaling-group-name my-asg \ --desired-capacity 2

If you choose to honor the default cooldown period for your Auto Scaling group, you must specify the –-honor-cooldown option as shown in the following example. For more information, see Scaling cooldowns for Amazon EC2 Auto Scaling.

aws autoscaling set-desired-capacity --auto-scaling-group-name my-asg \ --desired-capacity 2 --honor-cooldown
To verify the size of your Auto Scaling group

Use the describe-auto-scaling-groups command to confirm that the size of your Auto Scaling group has changed, as in the following example.

aws autoscaling describe-auto-scaling-groups --auto-scaling-group-name my-asg

The following is example output, which provides details about the group and instances launched.

{ "AutoScalingGroups": [ { "AutoScalingGroupName": "my-asg", "AutoScalingGroupARN": "arn", "LaunchTemplate": { "LaunchTemplateName": "my-launch-template", "Version": "1", "LaunchTemplateId": "lt-050555ad16a3f9c7f" }, "MinSize": 1, "MaxSize": 5, "DesiredCapacity": 2, "DefaultCooldown": 300, "AvailabilityZones": [ "us-west-2a" ], "LoadBalancerNames": [], "TargetGroupARNs": [], "HealthCheckType": "EC2", "HealthCheckGracePeriod": 300, "Instances": [ { "ProtectedFromScaleIn": false, "AvailabilityZone": "us-west-2a", "LaunchTemplate": { "LaunchTemplateName": "my-launch-template", "Version": "1", "LaunchTemplateId": "lt-050555ad16a3f9c7f" }, "InstanceId": "i-05b4f7d5be44822a6", "InstanceType": "t3.micro", "HealthStatus": "Healthy", "LifecycleState": "Pending" }, { "ProtectedFromScaleIn": false, "AvailabilityZone": "us-west-2a", "LaunchTemplate": { "LaunchTemplateName": "my-launch-template", "Version": "1", "LaunchTemplateId": "lt-050555ad16a3f9c7f" }, "InstanceId": "i-0c20ac468fa3049e8", "InstanceType": "t3.micro", "HealthStatus": "Healthy", "LifecycleState": "InService" } ], "CreatedTime": "2019-03-18T23:30:42.611Z", "SuspendedProcesses": [], "VPCZoneIdentifier": "subnet-c87f2be0", "EnabledMetrics": [], "Tags": [], "TerminationPolicies": [ "Default" ], "NewInstancesProtectedFromScaleIn": false, "ServiceLinkedRoleARN": "arn", "TrafficSources": [] } ] }

Notice that DesiredCapacity shows the new value. Your Auto Scaling group has launched an additional instance.

Terminate an instance 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 a specific instance. You can manually scale in your Auto Scaling group by using the terminate-instance-in-auto-scaling-group command and specifying the ID of the instance you want to terminate and the --should-decrement-desired-capacity option as shown in the following example.

aws autoscaling terminate-instance-in-auto-scaling-group \ --instance-id i-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\"}" } ] }

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.