Auto Scaling
Developer Guide (API Version 2011-01-01)
Did this page help you?  Yes | No |  Tell us about it...
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.

Expand Your Scaled and Load-Balanced Application to an Additional Availability Zone

When one Availability Zone becomes unhealthy or unavailable, Auto Scaling launches new instances in an unaffected Availability Zone. When the unhealthy Availability Zone returns to a healthy state, Auto Scaling automatically redistributes the application instances evenly across all of the designated Availability Zones for your Auto Scaling group. Auto Scaling does this by attempting to launch new instances in the Availability Zone with the fewest instances. If the attempt fails, however, Auto Scaling attempts to launch in other zones until it succeeds.

An Auto Scaling group can contain EC2 instances that come from one or more Availability Zones within the same region. However, an Auto Scaling group cannot span multiple regions. For information about the regions and Availability Zones supported by Auto Scaling, see Regions and Endpoints in the Amazon Web Services General Reference.

You can set up your load balancer to distribute incoming requests across EC2 instances in a single Availability Zone or multiple Availability Zones within a region. The load balancer does not distribute traffic across regions. For critical applications, we recommend that you distribute incoming traffic across multiple Availability Zones by registering your Auto Scaling group in multiple Availability Zones and then enabling your load balancer in each of those zones. Incoming traffic s load balanced equally across all the Availability Zones enabled for your load balancer.

If your load balancer detects unhealthy EC2 instances in an enabled Availability Zone, it stops routing traffic to those instances. Instead, it spreads the load across the remaining healthy instances. If all instances in an Availability Zone are unhealthy, but you have instances in other Availability Zones, Elastic Load Balancing routes traffic to your registered and healthy instances in those other zones. It resumes load balancing to the original instances when they have been restored to a healthy state and are registered with your load balancer.

You can expand the availability of your scaled and load-balanced application by adding a new Availability Zone to your Auto Scaling group and then enabling that Availability Zone for your load balancer. After you've enabled the new Availability Zone, the load balancer begins to route traffic equally among all the enabled Availability Zones.

You can use the Auto Scaling command line interface along with the Elastic Load Balancing CLI to add an Availability Zone to your application. For information about installing the Elastic Load Balancing CLI, see Installing the Command Line Interface in the Elastic Load Balancing Developer Guide.

Expanding Applications Using the Auto Scaling CLI

In this procedure, expand the availability of your application to an additional Availability Zone, us-east-1c.

To expand a scaled, load-balanced application to an additional Availability Zone using the CLI

  1. Use the as-update-auto-scaling-group command and specify the following values:

    • Auto Scaling group name = my-test-asg-lbs

    • Availability Zones = us-east-1a, us-east-1b, us-east-1c

    • Min size = 3

    Your command should look similar to the following example:

    as-update-auto-scaling-group my-test-asg-lbs --availability-zones us-east-1a, us-east-1b, us-east-1c --min-size 3

    You should get a confirmation similar to the following example:

    OK-Updated AutoScalingGroup
  2. Use the as-describe-auto-scaling-groups command and specify the following value:

    • Auto Scaling group name = my-test-asg-lbs

    Your command should look similar to the following example:

    as-describe-auto-scaling-groups my-test-asg-lbs --headers

    Auto Scaling responds with details about the group and instances launched. The information you get should be similar to the following example:

    AUTO-SCALING-GROUP  my-test-asg-lbs  my-test-lc    us-east-1c,us-east-1b,us-east-1a  my-test-asg-loadbalancer  3         6         3     Default
    INSTANCE  i-78e60b1b   us-east-1b         InService  Healthy  my-test-lc
    INSTANCE  i-dd4b2eb2   us-east-1c         InService  Healthy  my-test-lc
    INSTANCE  i-48a1cf29   us-east-1a         InService  Healthy  my-test-lc

    When the status of each of the new instances in the Auto Scaling group in the new Availability Zone changes to InService, this indicates that the instances are now ready to accept traffic from Elastic Load Balancing. You can then proceed to the next step.


    When you call the elb-enable-zones-for-lb command, the load balancer begins to route traffic equally among all of the enabled Availability Zones.

  3. Use the Elastic Load Balancing elb-enable-zones-for-lb command by specifying the following values:

    • Load balancer name = my-test-asg-loadbalancer

    • Availability Zone = us-east-1c

    Your command should look similar to the following example:

    elb-enable-zones-for-lb  my-test-asg-loadbalancer   --availability-zones us-east-1c --headers

    Elastic Load Balancing responds with a list of Availability Zones enabled for the load balancer. The information you get should be similar to the following example:

    AVAILABILITY_ZONES  us-east-1a, us-east-1b, us-east-1c

You have load-balanced your Amazon EC2 application across three Availability Zones and have scaled it in each zone.