Elastic Load Balancing helps distributing incoming traffic across multiple targets such as Amazon EC2 instances, microservices, and containers in one or more Availability Zones. It offers the following options –
- Application Load Balancer
- Network Load Balancer
- Classic Load Balancer
- Gateway Load Balancer
Application Load Balancer is one of the different types of Elastic Load Balancers options offered by AWS.
- It can distribute incoming HTTP and HTTPS traffic across multiple targets such as Amazon EC2 instances, microservices, and containers, based on request attributes
- You use an Application Load Balancer when you’re working with HTTP/HTTPS traffic.
- It Works at Layer 7 of the OSI model, at the Application Layer
- With ALB, you can configure to route incoming requests based on –
– Request Path
– Request Headers
– Request Method
– Query String
– Source IP
- For example, if you want your user requests coming from a mobile application be handled by one server, while requests coming from a web client by another, you can route requests from a mobile device to one destination, while requests from a desktop can be routed to another (like mobile requests from m.mywebsite.com, while desktop or tables route from mywebsite.com)
How does an ALB routes requests?
- To route requests to a destination, you configure a target group in an ALB
- A Target group for an ALB can be the following –
- Instance ID of an EC2
- IP address (Private IP)
- a Lambda function
How does an ALB decide where to route?
You can setup rules over the incoming requests (like requests coming from one host be routed to one group, while requests from another host be routed to another group).
These rules are setup based on the evaluation criteria using any of the above mentioned request attributes (path, host, headers..)
When a request is routed via an ALB to a target server / lambda, you cannot read the source IP address of the request – instead, the IP you get is a private IP, that of the ALB instance itself
If you require to obtain the IP address of the client which has sent the request, it is placed in the X-Forwarded-For request header