Elastic Load Balancing
Developer Guide (API Version 2012-06-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.

How Elastic Load Balancing Works

A load balancer accepts incoming traffic from clients and routes requests to its registered EC2 instances in one or more Availability Zones. The load balancer also monitors the health of its registered instances and ensures that it routes traffic only to healthy instances. When the load balancer detects an unhealthy instance, it stops routing traffic to that instance, and then resumes routing traffic to that instance when it detects that the instance is healthy again.

A load balancer routes traffic from clients to your EC2 instances.

You configure your load balancer to accept incoming traffic by specifying one or more listeners. A listener is a process that listens for connection requests. It is configured with a protocol and port number for connections from clients to the load balancer and from the load balancer to the instances.

When you attach an Availability Zone to your load balancer, Elastic Load Balancing creates a load balancer node in the Availability Zone that forwards traffic to the healthy registered instances in that Availability Zone. We recommend that you configure your load balancer across multiple Availability Zones. If one Availability Zone becomes unavailable or has no healthy instances, the load balancer can route traffic to the healthy registered instances in another Availability Zone.

Request Routing

Before a client sends a request to your load balancer, it resolves the load balancer's domain name using a Domain Name System (DNS) server. The DNS entry is controlled by Amazon, because your instances are in the amazonaws.com domain. The Amazon DNS servers return one or more IP addresses to the client. These are the IP addresses of the load balancer nodes for your load balancer. The client uses DNS round robin to determine which IP address to use to send the request to the load balancer.

The load balancer node that receives the request uses a routing algorithm to select a healthy instance. It uses the round robin routing algorithm for TCP listeners, and the least outstanding requests routing algorithm (favors the instances with the fewest outstanding requests) for HTTP and HTTPS listeners.

The cross-zone load balancing setting also determines how the load balancer selects an instance. If cross-zone load balancing is disabled, the load balancer node selects the instance from the same Availability Zone that it is in. If cross-zone load balancing is enabled, the load balancer node selects the instance regardless of Availability Zone.

The load balancer node routes the client request to the selected instance. If the instance is in a different Availability Zone than the load balancer node, the load balancer node routes the request to the load balancer node in the same Availability Zone as the instance, which then routes the request to the instance.

Availability Zones and Instances

To ensure that your back-end instances are able to handle the request load in each Availability Zone, it is important to keep approximately the same number of instances in each Availability Zone registered with the load balancer. For example, if you have ten instances in Availability Zone us-west-2a and two instances in us-west-2b, the traffic is equally distributed between the two Availability Zones. As a result, the two instances in us-west-2b serve the same amount of traffic as the ten instances in us-west-2a. Instead, you should distribute your instances so that you have six instances in each Availability Zone.

To distribute traffic evenly across all back-end instances, regardless of the Availability Zone, enable cross-zone load balancing on your load balancer. However, we still recommend that you maintain approximately equivalent numbers of instances in each Availability Zone for higher fault tolerance.