Skip to content

073 Elastic Load Balancer

Load Balancer

A server that forwards traffic to multiple servers downstream

Why use a load balancer?

  • Spread load across multiple downstream instances
  • Expose a single point of access (DNS) for your app
  • Seamlessly handle failures of downstream instances
  • Health check
  • SSL termination (HTTPS)
  • Enforce stickiness with cookies
  • High availability across zones
  • Separate public traffic from private traffic

Why use Elastic Load Balancer

It is a managed load balancer

  • AWS guarantess it will work
  • AWS takes care of upgrade, maintenance, high availability
  • AWS provides only a few config knobs

Your own load balancer

  • cost less
  • more effort

It is integrated with many AWS services

  • EC2, EC2 Auto Scaling groups
  • AWS Certificate Manager (ACM), CloudWatch
  • Route 53, AWS WAF, AWS Global Accelerator

Health Check

  • Crucial for load balancers
  • It enables the load balancer to know if instances are available to replay to requests
  • It is done on a port and a route (common endpoint: /health)
  • If response is not 200, then load balancer will not forward request

Types of load balancer on AWS

Classic load balancer (2009)

  • HTTP, HTTPS, TCP, SSL

Application load balancer (2016)

  • HTTP, HTTPS, WebSocket

Network load balancer (2017)

  • TCP, TLS, UDP

Gateway load balancer (2020)

  • Operates at network layer 3 (IP protocol)

It is recommended to use the newer generation

Some load balancers can be setup as internal or external ELB

Load Balancer Security Groups

Load balancer security group:

  • Looks like normal security group

Application security group:

  • Allow traffic only from the load balancer
    • Set Source as specific security group (which is load balancer)