Why did my Amazon EC2 Auto Scaling group scale in?

3 minute read
0

My Amazon Elastic Compute Cloud (Amazon EC2) Auto Scaling group scaled in without my intervention. I want to understand how that happened.

Resolution

Policies, users, and schedules scale your EC2 Auto Scaling groups. Termination policies control instance terminations when scale-in events happen.

To see your Auto Scaling group's scaling activity history, use the Amazon EC2 console, the AWS Command Line Interface (AWS CLI), or the AWS API.

Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshoot AWS CLI errors. Also, make sure that you're using the most recent AWS CLI version.

Policy-based scaling

If an Auto Scaling group follows a scaling policy to scale in, then a related event message appears in the activity history.

Example scale-in event message:

At 2023-05-08T13:55:14Z a monitor alarm My-Scale-In-Alarm in state ALARM triggered policy Decrease Group Size changing the desired capacity from 4 to 3.

Use the Amazon EC2 console or the AWS CLI put-scaling-policy command to adjust your scaling policy. Next, configure an Amazon CloudWatch alarm to set the conditions for your scale-in event. Then, associate CloudWatch alarm with your policy.

User-initiated scaling

If a user initiates an Auto Scaling group scale-in event, then a related event message appears in the activity history.

Example scale-in event message:

At 2023-05-13T15:03:47Z a user request update of AutoScalingGroup constraints to min: 12, max: 20, desired: 13 changing the desired capacity from 14 to 13.

See the associated AWS CloudTrail logs to find the user that made the scale-in event API call.

Note: CloudTrail must be set up before you can record API calls.

Scheduled scaling

If an Auto Scaling group follows a scheduled scaling policy to scale in, then a related event message appears in the activity history.

Example scale-in event message:

At 2023-02-12T16:01:25Z a scheduled action update of AutoScalingGroup constraints to min: 1, max: 5, desired: 2 changing the desired capacity from 3 to 2. 
At 2023-02-12T16:01:25Z the scheduled action ScaleIn executed. Setting max size from 1 to 5. Setting desired capacity from 3 to 2.

Run the following AWS CLI command to see a scheduled scale-in event:

aws autoscaling describe-scheduled-actions --auto-scaling-group-name my_scaling_group_name

Note: In your command, replace my_scaling_group_name with the name of your Auto Scaling group.

Related information

Tutorial: Set up a scaled and load-balanced application

Monitor CloudWatch metrics for your Auto Scaling groups and instances

Log Amazon EC2 Auto Scaling API calls with AWS CloudTrail

AWS OFFICIAL
AWS OFFICIALUpdated 4 months ago