AWS Insight: How ELB Works

    Hello! image

    I want to tell Habrahabr readers about the Elastic Load Balancer service , which is part of the Enterprise Compute Cloud. Many have long been using the ELB service, but do not know how the service works from the inside. I have a little knowledge of this information - many hours of meetings with AWS support are sometimes much more informative than the documentation on the site.

    So, let's start with the basics, then move on to the nuances.

    What is an ELB.


    Elastic Load Balancer is a service that provides request balancing between EC2 / VPC instances. Accordingly, there are 2 types of ELB that
    • visible from the Internet - EC2 / VPC
    • not visible from the Internet - VPC

    ELB Features


    ELB can proxy the following protocols:
    • http
    • https
    • tcp
    • ssl (secure tcp)

    Moreover, both listeners and recipients can be any combination. For example, http-http (just a proxy) or tcp - https (if SSL termination is done on the instance side)

    ELB can proxy ports:
    • 25
    • 80
    • 443
    • 1024-65535

    ELB setup


    In the console we find the item Load Balancers and there we click Create Load Balancer. The first screen is to configure ports and protocols:


    Next, because we chose HTTPS, we need a certificate for SSL termination. AWS asks us for the settings:


    Next, configure the helcheck - check host health. If the help is positive, the instance will be in the list for balancing. Negative - requests will not be sent to the instance:


    Helscheks can be configured on the same protocols as balancing, you can add a page name or path to http / https.

    Well, in the finale - you need to select the instances that you want to add under ELB (just an example in the screenshot)


    Last screen - as always checking details: We


    looked, decided that everything was OK and created ELB.

    How to set up a domain on ELB


    The EC2 ELB has 3 addresses to which you can access them. These 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 2 ways to configure your domain on ELB and they depend on which name servers you use. Amazon Route 53 is recommended because it is integrated with ELB and everything is easily configured there through A record:


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

    Sticky session


    ELB is capable of handling cookies for Sticky session. These functions can be configured in the configuration after creating the ELB:


    ELB autoscaling


    Here I would like to talk about how ELB scales and how it behaves under load. I already published an article comparing the performance of ELB, NGINX and HAproxy. There I touched on the moment of scaling. ELB vertically scaled from t1.micto to m1.small:
    image

    According to Amazon Web Services technical support representatives, increasing the load on ELB takes from one to seven minutes before the server is scaled. The IP address can be changed, so it is not recommended to use IP addresses for domains (I described the way out of the situation above).

    For individual cases, the ELB can be “warmed up” to the desired shape to withstand heavy loads. “Warming up is done” through requests for technical support.

    Auto Scale EC2 / VPC


    ELB plays an important role in autoscaling EC2 instances. The name ELB is indicated in the configs of autoscale groups and, in fact, everything revolves around them. You can read more about this in my article .

    ELB still has a lot of nuances of work, but I told the main thing.

    Do you have any experience with ELB? Interesting Facts?

    Also popular now: