Wednesday, January 30, 2013

AWS Insight: How ELB works


Hey! 


I’d like to tell the readers about Elastic Load Balancer service, which is included
into Enterprise Compute Cloud. Many people have been using ELB service for a long time, but they don’t know how the service works from the inside. I am a little informed on the subject - long-hour meetings with AWS support team are sometimes much more informative than the documentation on the website. 
So, let’s start with the basics, and then move on to the nuances. 

What is ELB.

Elastic Load Balancer — is the service that balances the load of queries between EC2/VPC instances. Correspondingly, there are two types of ELB, which are:

·         seen from the Internet — EC2/VPC
·         not seen from the Internet — VPC

ELB capabilities

ELB can proxy the following protocols:

·         http
·         https
·         tcp
·         ssl (secure tcp)

Both the listeners and the recipients can be of any combination. For example, http-http (just proxy) or tcp — https (in case SSL termination is done on the instance side).
 
ELB can proxy the following ports:

·         25
·         80
·         443
·         1024-65535

ELB configuration

You need to find Load Balancers option in the console and click Create Load Balancer. The first screenshot shows the settings of ports and protocols:


After that, as we chose HTTPS, we need the certificate for SSL termination. AWS asks for the following settings:


Next we configure health check to check the host health. In case when the health check is positive, the instance is added to the load balancer list. If negative – the requests will not be sent to the instance.


You can configure health checks to the same protocols you specified for the load balancing adjustments, or you can add a page name or a path for http/https.
And finally you need to choose instances which you want to add to ELB (just an example on the screenshot).


The last screenshot is as usual for reviewing your configuration details:


After you look them through, confirm that everything is OK, you create ELB.

How to configure a domain for ELB

EC2 ELB has three addresses which you can refer to. They are not IP addresses, but URLs:
·         myelb-1161081434.us-east-1.elb.amazonaws.com (A Record)
·         ipv6.myelb-1161081434.us-east-1.elb.amazonaws.com (AAAA Record)
·         dualstack.myelb-1161081434.us-east-1.elb.amazonaws.com (A or AAAA Record)
There are two ways to configure your domain for ELB, and they depend on which name servers you use. It is recommended to use Amazon Route 53 as it is integrated with ELB, and you can easily configure everything there via A record:



If you already use other DNS servers/ services, your path is CNAME.

Sticky session

ELB is able to process cookies for Sticky session. You can configure these functions in the options after creating ELB:


ELB auto scaling

In this section I would like to tell about how you can scale ELB and how it behaves during a high load. I have already published an article, which compares the productivity of ELB, NGINX and HAproxy. There I touched upon the scaling as well. ELB was scaled vertically from t1.micto to m1.small:

 
According to technical support of Amazon Web Services, when the load on ELB increases it can take from one and up to seven minutes before the server is scaled. IP address can be changed, so it is not recommended to use IP addresses for domains (I described the way out earlier).
 
In certain cases ELB can be ‘warmed-up’ to the size needed to cope with big loads. The ‘warming-up’ is carried out through the requests to technical support.

EC2/VPC auto scaling

ELB plays an important role in autoscaling of EC2 instances. ELB name is specified in the configuration of auto scaling groups, and in fact, everything is concentrated around them. ELB has some other functioning nuances, but I explained the basic points.
And do you have experience in working with ELB? Any interesting facts?

No comments:

Post a Comment