My AWS Elastic Beanstalk environment doesn’t scale the way that I expect it to.
Resolution
Prerequisites:
- Your Amazon Elastic Compute Cloud (Amazon EC2) instances have sufficient capacity to scale in your AWS Region. This capacity is based on the maximum number of instances that you define in your AWS Auto Scaling group configuration.
- You have a cooldown period that's based on the installation and configuration requirements of your application.
- You use default Amazon CloudWatch metrics or Locust to do a load test and identify the best metric to initiate scaling.
To configure your scaling triggers, use either the Elastic Beanstalk console or option settings.
Configure scaling triggers in the Elastic Beanstalk console
- Open the Elastic Beanstalk console, and then choose your environment.
- In the navigation pane, choose Configuration.
- For the Capacity category, choose Modify.
- In the Scaling Triggers section, choose your trigger options, and then choose Apply.
Note: Elastic Beanstalk provides configuration options for Auto Scaling settings in the aws:autoscaling:trigger namespace. Settings in this namespace are organized by the resource that they apply to.
Configure scaling triggers with option settings
Use .ebextensions in option settings to modify your scaling configurations. To access the configuration file that's used to configure your scaling triggers, see autoscaling-triggers-customize.config on the GitHub website.
The following example configuration file modifies the scaling triggers that are based on CPU utilization. If CPU utilization across all instances is more than 80 percent over three consecutive two-minute periods, then one instance is added to the Auto Scaling group. If CPU utilization across all instances is less than 20 percent for the same period, then one instance is removed from the Auto Scaling group.
option_settings:
aws:autoscaling:trigger:
MeasureName: CPUUtilization
Statistic: Average
Unit: Percent
Period: '2'
EvaluationPeriods: '3'
UpperThreshold: '80'
UpperBreachScaleIncrement: '1'
LowerThreshold: '20'
LowerBreachScaleIncrement: '-1'
The following example shows the structure of the .ebextensions directory and autoscaling-triggers-customize.config file in the application zip file:
~/my-app/
|-- .ebextensions/
| |-- autoscaling-triggers-customize.config
| `-- other.config
|-- other application files
Related information
Auto Scaling triggers