Elastic Load Balancer (ELB)

  1. Three types
    1. Classic LB (for classic EC2) uses Transport layer (L4) or application layer (L7) of TCP/IP
    2. Application LB uses application layer of TCP/IP
    3. Network ELB (TCP)
  2. How to Create ELB
    1. Choose type of ELB
    2. Name, internal or internet facing, VPC
    3. ELB Protocol, ELB Port
      1. For Classic choose HTTP/HTTPS/TCP/SSL
      2. For application ELB choose HTTP/HTTPS
      3. Tor Network ELB choose TCP/Port
    4. Instance protocol, Instance port
    5. Assign Security Group
    6. Configure health check
      1. Ping protocol/port/path (example: /test.html)
      2. Response timeout (amount of time before response starts)
      3. Interval (amount of time between pings)
      4. Unhealthy threshold (number of consecutive failures before declaring instance unhealthy)
      5. Healthy threshold (number of consecutive pass before declaring instance healthy)
    7. Add EC2 instances
      1. Add one or more EC2s directly for classic ELB
      2. For Network ELB and Application ELB, create a new Target Group or use existing target group
        1. TG needs Name, Protocol, Port, Target Type (Instance id or ip)
        2. Add EC2 instances (instance id) or private ip/port to the TG
  3. After creating ELB note the DNS name: elbname.regionname.elb.amazonaws.com which can be updated in your DNS
  4. Session management (AWS documentation on ELB session management)
    1. By default, a Classic Load Balancer routes each request independently to the registered instance with the smallest load. However, you can use the sticky session feature (also known as session affinity), which enables the load balancer to bind a user’s session to a specific instance. This ensures that all requests from the user during the session are sent to the same instance.
    2. Stickiness can be setup thru console or CLI
    3. Elastic Load Balancing creates a cookie, named AWSELB, that is used to map the session to the instance.
    4. Duration based session stickiness:
      1. On the Edit stickiness page, select Enable load balancer generated cookie stickiness.
      2. (Optional) For Expiration Period type the cookie expiration period, in seconds. If you do not specify an expiration period, the sticky session lasts for the duration of the browser session.
      3. If there is no cookie (first request), the load balancer chooses an instance based on the existing load balancing algorithm (least loaded EC2). A cookie is inserted into the response for binding subsequent requests from the same user to that instance.  After a cookie expires (after duration from above step), the session is no longer sticky.
    5. Application-Controlled session stickiness:  
      1. The load balancer uses a special cookie to associate the session with the instance that handled the initial request, but follows the lifetime of the application cookie specified in the policy configuration.
      2. The load balancer only inserts a new stickiness cookie if the application response includes a new application cookie.
      3. The load balancer stickiness cookie does not update with each request.
      4. If the application cookie is explicitly removed or expires, the session stops being sticky until a new application cookie is issued.
      5. If an instance fails or becomes unhealthy, the load balancer stops routing requests to that instance, and chooses a new healthy instance based on the existing load balancing algorithm.
      6. The load balancer treats the session as now “stuck” to the new healthy instance, and continues routing requests to that instance even if the failed instance comes back.
      7. On the Edit stickiness page, select Enable application generated cookie stickiness.
      8. For Cookie Name, type the name of your application cookie.
    6. ELB can distribute load across EC2 instances running across AZs within a region only.
<<< Elastic Block Storage (EBS)Auto Scaling Groups and Launch Configurations >>>
Copyright 2005-2016 KnowledgeHills. Privacy Policy. Contact .