Beruflich Dokumente
Kultur Dokumente
TCP buffering. The load balancer can buffer responses from the server
and spoon-feed the data to slow clients, allowing the server to move on
to other tasks.
Load balancing should not be viewed as a replacement for faulttolerant architectures. When load balancing is implemented, a server
that fails will remain offline and, in the event of round robin DNS, will
still be sent requests.
Cons
In both scenarios, the web server will respond to requests by handing out the
next IP address in the list to the requesting client.
In the Amazon EC2 environment, you can more effectively manage the order
or round robin requests through the use of Elastic IPs. By using Elastic IPs,
you can remap the IP address from a failed instance to another working
instance. You have two avenues to complete this task: programmatically or
by directly altering the DNS entries on the server. Both methods are
presented here.
Using HA Proxy with Amazon EC2
HA Proxy is another technology that you can use with load balancing. HA
Proxy is a software solution designed to provide proxying for both TCP- and
HTTP-based applications. In the following example, you will install HA Proxy
into the Amazon EC2 environment and perform some initial configuration to
get the solution running.
The first step to implementing HA Proxy on Amazon EC2 is to customize an
Amazon Machine Image (AMI). To launch this AMI, open a command-line
window. Set up a command-line environment by using the EC2_PRIVATE_KEY
and EC2_CERT environment variables, then issue the command ec2-runinstances ami-6a57b203 -k my-keypair, where my-keypair is the name of the
keypair you were issued to log in remotely to public Amazon EC2 AMIs.
Note: If you prefer GUIs over command-line tools, you can use the fantastic
Firefox extension Elasticfox to launch and manage your instances.
enables you to increase the availability of your application. You can add
and remove EC2 instances from your load balancer as your needs
change, without disrupting the overall flow of information. If an EC2
instance fails, Elastic Load Balancing automatically reroutes the traffic
to the remaining running EC2 instances. If a failed EC2 instance is
restored, Elastic Load Balancing restores the traffic to that instance.
Elastic Load Balancing can also serve as the first line of defense
against attacks on your network. You can offload the work of
encryption and decryption to your load balancer so that your EC2
instances can focus on their main work.
Features of Elastic Load Balancing
You can use the operating systems and instance types supported by
Amazon EC2. You can configure your EC2 instances to accept traffic
only from your load balancer.
You can configure the load balancer to accept traffic using the following
protocols: HTTP, HTTPS (secure HTTP), TCP, and SSL (secure TCP).
You can configure the health checks that Elastic Load Balancing uses to
monitor the health of the EC2 instances registered with the load
balancer so that it can send requests only to the healthy instances.
You can use end-to-end traffic encryption on those networks that use
secure (HTTPS/SSL) connections.
You can monitor your load balancer using CloudWatch metrics, access
logs, and AWS CloudTrail.
You can associate your Internet-facing load balancer with your domain
name. Because the load balancer receives all requests from clients,
you don't need to create and manage public domain names for the EC2
instances to which the load balancer routes traffic. You can point the
instance's domain records at the load balancer instead and scale as
needed (either adding or removing capacity) without having to update
the records with each scaling activity.
You configure your load balancer to accept incoming traffic by specifying one
or more listeners. A listener is a process that checks for connection requests.
It is configured with a protocol and port number for connections from clients
to the load balancer and a protocol and port number for connections 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
theamazonaws.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. As traffic to your application changes over
time, Elastic Load Balancing scales your load balancer and updates the DNS
entry. Note that the DNS entry also specifies the time-to-live (TTL) as 60
seconds, which ensures that the IP addresses can be remapped quickly in
response to changing traffic.
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.
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-west2a and two instances in us-west-2b, the requests are distributed evenly
between the two Availability Zones. As a result, the two instances in us-west2b serve the same amount of traffic as the ten instances in us-west-2a.
Instead, you should 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 better fault tolerance.
Prepare Your VPC and Back-end Instances