The Elastic Load Balancer (ELB) distributes traffic across different instances. It spans the region and uses ever Availability Zone (AZ). ELB is inherently secure, resilient, scalable but the client is responsible for configuring it properly. ELB integrates seamlessly with Route 53 and Auto Scaling and support health checks. For example, when a health check fails on an instance, ELB stops traffic to the instance and distributes the traffic to other instances. If health check detects too much load, it communicates with auto scaling so that new instances can be started. ELB itself is inherently scalable and self-healing.

There are three types of load balancers: classic, application, network:

Classic Load Balancer (CLB):

To setup classic load balancer, you need to setup ports to listen to and register instances. For example, port 80 is registered to instance ab1 and port 443 is registered to ab2. ELB will then forward all port 80 traffic to ab1 instance and port 443 traffic to ab2 instance.

Application Load Balancer (ALB):

To setup application load balancer, you need to setup ports to listen to. Then you create target groups where each target group has one or more registered instances. Incoming traffic filtered by pre-defined rules to forward to the relevant target group. ALB supports dynamic port mapping i.e. it allows one instance to accept traffic from multiple ports. Other features include:

  • support for http, https, http/2, and websocket protocols
  • CloudWatch metrics, access logs, health checks
  • path and host-based routing
  • native IPv6 support
  • AWS WAF support
  • deletion protection and request tracing

ALB is ideal for micro-services.

Network Load Balancer (NLB):

To setup network load balancer, you need to setup ports to listen to. Then you create target groups where each target group has one or more registered instances. It allows use of static IPs. NLB is ideal for connections that need to keep connections open for a long time.

How to create load balancer:

  1. Login > EC2
  2. Load Balancers
  3. Create Load Balancer
  4. Keep default
  5. Fill in the form

By master