How to Expand a Load Balanced Application to an Additional Availability Zone
In this example, you expand your EC2 application to run in an additional Availability Zone (us-east-1b
). To do so, you first register the instances in the Availability Zone us-east-1b with the LoadBalancer. You wait for the instances to show up in the OutOfService state for the LoadBalancer. Finally you enable Availability Zone us-east-1b for your LoadBalancer.
Note | |
---|---|
It is important to register instances in the new Availability Zone with your LoadBalancer
before adding the Availability Zone. When you call |
Preconditions:
-
You have set up an HTTP LoadBalancer in Availability Zone us-east-1a as in Setting up a Load Balance to Use HTTP.
-
In Availability Zone us-east-1b, you have launched the instances you intend to register with your LoadBalancer.
API Example
To expand a load balanced application to an additional Availability Zone
-
Call RegisterInstancesWithLoadBalancer with the following parameters:
-
LoadBalancerName
=MyLoadBalancer
-
Instances = [
i-3a8cf324
,i-2603ca33
]
-
-
Call DescribeInstanceHealth with the following parameters.
-
LoadBalancerName
=MyLoadBalancer
-
Instances =
i-3a8cf324
,i-2603ca33
-
-
When the instances from the previous step are in the OutOfService state, you can proceed to the next step. Call EnableAvailabilityZonesForLoadBalancer.
-
LoadBalancerName
=MyLoadBalancer
-
Availability Zones =
us-east-1b
-
The operation returns the updated list of Availability Zones enabled for your LoadBalancer.
Command Line Tools Example
To expand a load balanced application to an additional Availability Zone
-
Use the elb-register-instances-with-lb command as in the following example.
PROMPT> elb-register-instances-with-lb MyLoadBalancer --headers --instances i-3a8cf324, i-2603ca33
Elastic Load Balancing returns the following:
INSTANCE INSTANCE-ID INSTANCE i-3a8cf324 INSTANCE i-2603ca33 INSTANCE i-4f8cf126 INSTANCE i-0bb7ca62
-
Use the elb-describe-instance-health command as in the following example.
PROMPT> elb-describe-instance-health MyLoadBalancer --headers --instances i-3a8cf324,i-2603ca33
Elastic Load Balancing returns the following:
INSTANCE INSTANCE-ID STATE INSTANCE i-3a8cf324 OutOfService INSTANCE i-2603ca33 OutOfService
-
Use the elb-enable-zones-for-lb command as in the following example.
PROMPT>elb-enable-zones-for-lb MyLoadBalancer --headers --availability-zones us-east-1b
Elastic Load Balancing returns the following:
AVAILABILITY_ZONES AVAILABILITY-ZONES AVAILABILITY_ZONES us-east-1a, us-east-1b
Give Us Your Feedback
Your input is important to us to help make our documentation helpful and easy to use. Please take a minute to give us your feedback on how well we were able to help you use Elastic Load Balancing. Just click this feedback link. Thank you.