AWS ELB Study Notes

Yst@IT
4 min readAug 13, 2019

--

AWS ELB

For ALB and CLB, you can get client IP with X-Forwarded-For header when using HTTP service ONLY. You need to enable and deploy Proxy Protocol in backend services to get client IP.

To get client IP from X-Forwarded-For header, modify web service. For example in httpd, add %{X-Forwarded-For}i in the httpd.conf file. Source IP will show in apache access log.

AWS ELB

When creating target group, you can choose instance ID OR IP. For instance ID, you can only choose instance from AWS. For IP, you can choose IPs from network segment below, which means you can choose database or on-premises resources if connected through Direct Connect or VPN. For IPs, you can’t specify publicly routable IP addresses.

  • The subnets of the VPC for the target group
  • 10.0.0.0/8 (RFC 1918)
  • 100.64.0.0/10 (RFC 6598)
  • 172.16.0.0/12 (RFC 1918)
  • 192.168.0.0/16 (RFC 1918)

ALB uses round robin routing algorithm.

NLB uses flow hash algorithm. Each individual TCP connection is routed to a single target for the life of the connection.

CLB uses round robin routing algorithm for TCP listeners and the least outstanding requests routing algorithm for HTTP and HTTPS listeners.

If choose Internet facing ELB, public subnet must be chosen.

For NLB:

  1. Only supports TCP, TLS and UDP and TCP_UDP.
  2. You must register targets by instance ID so the source IP addresses of the clients are preserved and provided to your applications.
  3. If the target group protocol is UDP or TCP_UDP, the target type must be instance.
  4. Do not support the lambda target type, only Application Load Balancers support.
  5. If you specify targets using an instance ID, traffic is routed to instances using the primary private IP address. Load balancer rewrites the destination IP address from the data packet before forwarding it to the target instance.
  6. If you specify targets using IP addresses, you can route traffic to an instance using any private IP address from one or more network interfaces. The load balancer rewrites the destination IP address before forwarding it to the target.
  7. If you specify targets using an instance ID, the source IP addresses of the clients are preserved and provided to your applications. However, if you prefer, you can enable Proxy Protocol and get the client IP addresses from the Proxy Protocol header.
  8. If you specify targets by IP address, the source IP addresses are the private IP addresses of the load balancer nodes. If you need the IP addresses of the clients, enable Proxy Protocol and get the client IP addresses from the Proxy Protocol header.
  9. Before you enable Proxy Protocol on a target group, make sure that your applications expect and can parse the Proxy Protocol v2 header, otherwise, they might fail.
AWS ELB

For CLB

  1. Only supports HTTP, HTTPS, TCP and SSL.
  2. By default, when you use TCP for both front-end and back-end connections, CLB forwards requests to the instances without modifying the request headers. If you enable Proxy Protocol, a human-readable header is added to the request header with connection information such as the source IP address, destination IP address, and port numbers. The header is then sent to the instance as part of the request.

For ALB:

  1. Only supports HTTP and HTTPS.
  2. If target group is configured with the HTTPS protocol or uses HTTPS health checks, SSL/TLS connections to the targets use the security settings from the ELBSecurityPolicy2016-08 policy.
  3. It has slow start mode. By default, a target starts to receive its full share of requests as soon as it is registered with a target group and passes an initial health check. Using slow start mode gives targets time to warm up before the load balancer sends them a full share of requests.

ELBs Comparison.

AWS ELB

Demo:

AWS ELB
AWS ELB

--

--

Yst@IT
Yst@IT

Written by Yst@IT

Cloud Solution Architect, focusing on Oracle Cloud Infrastructure currently.