• a load balancer automatically distributes traffic across multiple EC2 instances.
  • load balancer options
    • we can manage our own virtual load balancers on EC2 instances
    • leverage an AWS Cloud service – ELB or Elastic Load Balancing, a managed load balancer

Features of Elastic Load Balancing

  • ELB allows distribution of traffic across a group of EC2 instances in one or more AZs
  • It achieves high availability in applications.
  • For traffic to EC2 instances, ELB supports routing and load balancing of
    • HTTP
    • HTTPS
    • TCP
    • SSL
  • ELB allows a stable, single CNAME entry point for DNS configuration supporting Internet-facing and internal application-facing load balancers.
  • ELB supports health checks for EC2 instances
  • It ensures that the traffic is not routed to unhealthy or failing instances.
  • It can also automatically scale based on collected metrics.

Benefits of Elastic Load Balancing

  • managed service, that scales in and out automatically as per demands of increased application traffic
  • It is highly available within a region itself as a service.
  • It helps to achieve high availability for applications by distributing traffic across healthy instances in multiple AZs.
  • Its helps to seamlessly integrate with the Auto Scaling service to automatically scale EC2 instances.
  • It is secure, working VPC to route traffic internally between application tiers, allowing to expose only Internet-facing public IP addresses.
  • supports integrated certificate management and SSL termination.

Types of Load Balancers

  • Internet-Facing Load Balancers: takes requests from clients over Internet and distributes them to EC2 instances registered with load balancer. During configuration public DNS name is needed to be used by clients to send requests . Load balances external traffic
  • Internal Load Balancers: It load balances between different tiers of application. Used to route traffic to EC2 instances in VPCs with private subnets.
  • HTTPS Load Balancers: load balancer uses the SSL/ TLS protocol for encrypted connections or SSL offload. Traffic encryption between load balancer and clients that initiate HTTPS sessions, and for connections between load balancer and back-end instances. SSL certificate must be installed on load balancer. ELB does not support SNI on load balancer.

Listeners

  • every load balancer must have one or more listeners configured.
  • A listener is a process that checks for connection requests.
  • Listener is configured with a protocol for
    • port for front-end (client to load balancer)
    • port for back-end (load balancer to EC2 instance) connection
  • ELB supports protocols like – HTTP, HTTPS, TCP and SSL.

Configuring Elastic Load Balancing

Configure aspects of load balancer as

  • idle connection timeout
    • cross-zone load balancing
    • connection draining
    • proxy protocol
    • sticky sessions
    • health checks
  • configuration settings can be modified using by
    • AWS Management Console
    • Command Line Interface (CLI).

Idle Connection Timeout

  • Every request that a client makes through a load balancer, it maintains two connections
    • one with client
    • other connection to back-end instance
  • For each connection, the load balancer manages an idle timeout
  • idle timeout is triggered when no data is sent over connection for a specified time period.
  • After lapse of idle timeout period, if no data has been sent or received, load balancer closes the connection.
  • By default, idle timeout is 60 seconds for both connections.
  • Increase idle timeout setting for lengthy operations like file uploads

Cross Zone Load Balancing

  • Enable cross-zone load balancing on load balancer so that request traffic is routed evenly across all back-end instances for load balancer, regardless of AZs
  • It reduces need to maintain equivalent numbers of back-end instances in each AZ
  • Application can handle the loss of one or more back-end instances.
  • But, recommended to maintain approximately equivalent numbers of instances in each AZ for higher fault tolerance.

Connection Draining

  • enabling it will make load balancer stop sending requests to instances that are de-registering or unhealthy, while keeping the existing connections open.
  • This enables the load balancer to complete in-flight requests made to these instances.

Proxy Protocol

  • load balancer forwards requests to the back-end instances without modifying the request headers
  • With Proxy Protocol a human-readable header is added
  • Following are added
    • source IP address
    • destination IP address
    • port numbers
  • load balancer is not behind a proxy server with Proxy Protocol enabled

Sticky Sessions

  • also called as session affinity
  • It allows load balancer to bind a user’s session to a specific instance.
  • Hence, all requests from user during session are sent to same instance.
  • Before enabling, determine how long load balancer should consistently route the user’s request to same instance.
  • If application has own session cookie, then configure ELB, session cookie follows duration specified by the application’s session cookie.
  • If application has no own session cookie, then configure ELB to create a session cookie by specifying our own stickiness duration.
  • ELBcreates cookie called AWSELB to map session to instance.

Health Checks

  • ELB conducts health checks to test status of EC2 instances behind an ELB load balancer.
  • All healthy instances during health check are termed as ‘InService’
  • unhealthy instances are termed as ‘OutOfService’.
  • The load balancer performs health checks on all registered instances.
Menu