One of the new hotness features that Amazon added to their Elastic Load Balancers is cross zone load balancing. This offers the ability to have an unbalanced number of nodes per availability zone within an Amazon region. For instance, if you were load balances across us-east-1a, us-east-1b, and us-east-1c, then you needed to have the same number of instances in each zone otherwise the traffic would skew and overload the zone with fewer instances. If you are auto-scaling, using spots, or just happen to lose instances from time to time, you can easily see where this becomes a problem.
The idea of the feature is great. The problem comes in when you go to add cross zone load balancing to one of you ELBs. Since it’s not available in the AWS console, you need to do it by hand. I chose to use the Python CLI tools which can be installed using the documentation here. To get this to work, ensure that you have the configuration done (more information available on that here).
After you are all configured, you will need to grab the name of your load balancer. We will use MyLoadBalancer. Using the command line tools and JSON (since JSON is the easiest to get going), run the modify-load-balancer-attributes command under the ELB option of the AWS command line tools and change the attributes.
First let’s verify that we can see the attributes of the load balancer correctly. Notice that the CrossZoneLoadBalancing attribute is not enabled.
1 2 3 4 5 6 7 8 | $ bin/aws elb describe-load-balancer-attributes --load-balancer-name MyLoadBalancer { "LoadBalancerAttributes": { "CrossZoneLoadBalancing": { "Enabled": false } } } |
Now let’s enable the attribute.
1 2 3 4 5 6 | ~$ bin/aws elb modify-load-balancer-attributes --load-balancer-name MyLoadBalancer \ --load-balancer-attributes '{ "CrossZoneLoadBalancing": { "Enabled": true } }' |
To test your changes, you can run a similar attributes command only with describe instead of modify. You will notice the value of Enabled has changed to true.
1 2 3 4 5 6 7 8 | $ bin/aws elb describe-load-balancer-attributes --load-balancer-name MyLoadBalancer { "LoadBalancerAttributes": { "CrossZoneLoadBalancing": { "Enabled": true } } } |
Note: I finally found all this documentation here. I threw this post together for others to be able to find this information all in one place.