AWS Elastic Beanstalk
Developer Guide (API Version 2010-12-01)
AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Auto Scaling Health Check Setting

By default, the Auto Scaling created for your environment uses Amazon EC2 status checks. If an instance in your environment fails an EC2 status check, it is taken down and replaced by Auto Scaling.

EC2 status checks only cover an instance's health, not the health of your application, server, or any Docker containers running on the instance. If your application crashes, but the instance that it runs on is still healthy, it may be kicked out of the load balancer, but it won't be replaced automatically by Auto Scaling.

Note

Configuring a health check URL in the Load Balancing configuration section of the Elastic Beanstalk console does not affect the health check behavior of an environment's Auto Scaling group.

You may want instances in your environment to stay up when the application crashes for troubleshooting and recovery purposes. If Auto Scaling replaced the instance as soon as the application crashed, you may not realize that anything went wrong, even if it crashed quickly after starting up.

If you would like Auto Scaling to restart instances whose application has stopped responding, you can configure the Auto Scaling group to use Elastic Load Balancing health checks with an .ebextensions configuration file.

Note

Enabling this option can cause your environment to continually terminate and replace instances if the Elastic Load Balancing health check fails soon after an instance starts. If this happens, change the health check type back to EC2 in the Auto Scaling management console, or reverse the configuration change and redeploy your environment.

To set the Auto Scaling health check to ELB during environment launch

  1. Create a .ebextensions directory in your project folder.

  2. Create a config file in the .ebextensions folder with the following content:

    .ebextensions/autoscaling.config

    Resources:
      AWSEBAutoScalingGroup:
        Type: "AWS::AutoScaling::AutoScalingGroup"
        Properties:
          HealthCheckType: ELB
          HealthCheckGracePeriod: 300

    The grace period setting sets the number of seconds that an instance can fail the health check without being terminated and replaced. Instances may recover even after being kicked out of the load balancer, so give the instance an amount of time that is appropriate for your application.

  3. Deploy or update your environment.

By default, the Elastic Load Balancing health check is configured to attempt a TCP connection to your instance over port 80. This confirms that the web server running on the instance is accepting connections, but you may want to customize the check to make sure that your application is in a good state, not just the web server.

You can tell Elastic Load Balancing to use a different port or to make an HTTP GET request to a path that your application uses by changing the Elastic Load Balancing configuration for your environment. See Configuring the Load Balancer in your Elastic Beanstalk Environment for details.