How do I troubleshoot issues with scaling triggers in Elastic Beanstalk?

3 minute read
0

My AWS Elastic Beanstalk environment isn't scaling the way that I expected.

Short description

The Auto Scaling group in your Elastic Beanstalk environment uses two Amazon CloudWatch alarms to trigger scaling operations. Default Auto Scaling triggers are configured to scale under certain conditions. The triggers scale when the average outbound network traffic from each instance is higher than 6 MB or lower than 2 MB for five minutes.

To use Amazon EC2 Auto Scaling effectively, you must configure scaling triggers that are appropriate for your application, instance type, and service requirements.

Note: You can scale your environment based on several statistics, including latency, disk I/O, CPU utilization, and request count. In advanced scenarios, consider using .ebextensions based on custom metrics such as memory.

Before you start the steps in the Resolution section, confirm the following:

  • You have sufficient capacity for your Amazon Elastic Compute Cloud (Amazon EC2) instances to scale in your AWS Region. This capacity is based on the maximum number of instances that can be contained in the Auto Scaling group defined in your environment configuration.
  • You have a cooldown period set, if necessary, based on the installation and configuration requirements of your application.
  • You have identified the best metric for your environment to trigger by load testing with default CloudWatch metrics or load generating and testing with Locust.

Resolution

To configure your scaling triggers, complete the steps using either the Elastic Beanstalk console or option settings:

Configure scaling triggers in the Elastic Beanstalk console

1.    Open the Elastic Beanstalk console, and then choose your environment.

2.    In the navigation pane, choose Configuration.

3.    For the Capacity category, choose Modify.

4.    In the Scaling Triggers section, choose the triggering options based on your needs, 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

Modify your scaling configurations using .ebextensions in option settings.

The following example modifies the scaling triggers to be based on CPU utilization. If CPU utilization across all instances is above 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 below 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'

AWS OFFICIAL
AWS OFFICIALUpdated 2 years ago