> For the complete documentation index, see [llms.txt](https://karansingh.gitbook.io/aws-saa-c02/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://karansingh.gitbook.io/aws-saa-c02/elb/application-load-balancer-alb.md).

# Application Load Balancer (ALB)

## Overview

* It **functions at the application layer** (the seventh layer of the OSI model) (**HTTP**).<br>
* After the load balancer receives a request, it **evaluates the listener rules in priority order to determine which rule to apply**, and **then selects a target from the target group** for the rule action.<br>
* You **can configure listener rules to route requests to different target groups based on the content of the application traffic**.<br>
* **Routing is performed independently for each target group**, even when a target is registered with multiple target groups.<br>
* You **can configure the routing algorithm used at the target group level**.&#x20;

## Components

* **Load balancer**
  * **Serves as the single point of contact for clients**.
  * The load balancer **distributes incoming application traffic across multiple targets**.
  * You **add one or more listeners to your load balancer**.<br>
* **Listener**
  * You **must add one or more listeners**.
  * It **checks for connection requests from clients, using the protocol and port that you configure**.
  * **Rules determine how the load balancer routes requests to its registered targets**.<br>
* **Target group**
  * The **target group could contain:**
    * An **IP address**.
    * **EC2 Instances**.
    * **Lambda functions**.
  * You **can register a target with multiple target groups**.
  * When you create each listener rule, you specify a target group and conditions.
  * When a rule condition is met, traffic is forwarded to the corresponding target group.
  * You can **create different target groups for different types of requests**.
    * E.g. you can create one target group for general requests and another target group for requests to the microservices for your application.

## Support For

* **Path conditions.**
  * You **can configure rules for your listener that forward requests based on the URL in the request**.
    * This **enables you to structure your application as smaller services, and route requests to the correct service based on the content of the URL**.<br>
* **Host conditions.**
  * You **can configure rules for your listener that forward requests based on the host field in the HTTP header**.
    * This **enables you to route requests to multiple domains** using a single load balancer.<br>
* **Routing based on fields in the request, such as HTTP header conditions and methods, query parameters, and source IP addresses**.<br>
* **Redirecting requests from one URL to another**.<br>
* **Returning a custom HTTP response**.

## HTTP headers <a href="#x-forwarded-headers" id="x-forwarded-headers"></a>

* **HTTP requests and HTTP responses use header fields to send information about the HTTP messages**.<br>
* ALBs **support the following** `X-Forwarded` headers:
  * **X-Forwarded-For**
  * **X-Forwarded-Proto**
  * **X-Forwarded-Port**
