Bharathi Batthula
5 min readJun 12, 2020

--

AWS: ApplicationLoad Balancer

Serves as the single point of contact for clients. The load balancer distributes incoming application traffic across multiple targets, such as EC2 instances, in multiple Availability Zones.

ALB

AWS ALB Components- Listeners

Listeners define the protocol/port combination that the ALB will listen on for incoming requests.

A listener checks for connection requests from clients using the protocol and port that you configure, and forward requests to one or more target groups, based on the rules that you define.

Each ALB requires at least one listeners to accept traffic.

Currently, 50 Listeners can be configured on the ALB.

Supported Protocols: HTTP/HTTPS

  • Ports 1–65535

AWS ALB Components- Target Groups

Target Groups:

  • Are regional constructs.
  • A Target Group is a logical grouping of Targets.
  • Note that each target group can be associated with only one load balancer.
  • Each target group can be associated with only one load balancer.
  • Groups can scale each target group individually.
  • The target group is used to route requests to registered targets as part of an action for a rule.
  • The target group specifies a protocol and target port.
  • Health checks can be configured per target groups.
  • An ALB can route to multiple target groups.
  • You define one Protocol and one port per target group which will be used to route/forward traffic to the registered targets.
  • They can exist independently from the ALB.

AWS ALB- Targets

Targets:

Targets specify the endpoints and are registered with the ALB as part of a target group.

Targets can be EC2 instance, a Microservice, and the Application on an ECS container, or IP addresses.

  • You can’t specify public internet routable IP addresses as targets.

An EC2 instance can be registered with the same target group multiple times using multiple ports.

Up to 1000 target can be contained within a target group.

You can register a target with multiple target groups.

You can add and remove targets from your load balancer as your needs change, without distributing the overall flow of requests to your application.

AWS ALB- Targets-Type: IP address

You can use IP addresses as targets to register:

  • Instances in a peered VPC,
  • AWS resources that are addressable by IP address and port (for example, databases),

You can register each EC2 instance or IP address with the same target group multiple times using different ports, which enables the load balancer to route requests to microservices.

If you specify targets using an instance ID, traffic is routed to instances using the primary private IP address specified in the primary network interface for the instance.

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.

  • This enables multiple applications on an instance to use the same port.

AWS ALB Components- Target Group and Targets

You CAN NOT mix targets of different types in one target group, i.e you can not mix EC2 with ECS and/or IP targets in one target group

  • You need to keep the endpoint type homogenous in each group

IP targets are targets within the VPC or on-premise accessible through a VPN and DX

  • They CAN NOT be public, internet-routable, IP addresses

You can configure health checks on a per target group basis.

  • Health checks are performed on all targets registered to a target group that is specified in a listener rule for your load balancer.

By default, the load balancer sends request to registered targets using the port and protocol that you specified for the target group.

You can delete a target group if it is not referenced by any actions.

Deleting a target group does not affect the targets registered with the target group. If you no longer need a registered EC2 instance, You can stop or terminate it.

AWS ALB Components- Rules (or Routing Rules)

Rules provide a link between listeners and target groups and consist of conditions and actions.

  • Up to 100 rules can be configured per ALB
  • Rules determine what action is taken when a rule matches a client request.
  • Rules are defined on listeners
  • Each rule specifies a condition, target group, action, and a priority. (When the condition is met, the traffic is forwarded to the target group.
  • Each rule represents a condition and action that we want to follow.
  • You must define a default rule of each listener, and you add rules that specify different target groups based on the content of the request (also known as content-based routing)
  • If no rules are found, the request will follow the default rule, which forwards the request to the default target group.

AWS ALB- Listener Rules

Rule Priority

Each rule has a priority.

Rules are evaluated in priority order, from the lowest value to the highest value.

The default rule is evaluated last.

You can change the priority of a non-default rule at any time.

You cannot change the priority of the default rule.

Rule Actions

When you create a listener, you define an action for the default rule.

Default rules can’t have conditions.

You can delete the no- default rules for listeners at any time. You cannot delete the default rule for a listener. When you delete a listener, all its rules are deleted.

If no conditions for any of a listeners rules are met, then the action for the default rule is taken.

Rule Conditions

There are two types of rule conditions: host and path.

When the conditions for a rule are met, then its action is taken.

Each rule can have up to 2 conditions. 1 Path Condition and 1 Host Condition.

Optional Condition is the path pattern you want the ALB to evaluate in order for it to route requests.

AWS ALB- Request Routing

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 group for the rule action using the round-robin routing algorithm.

Your load balancer routes request to the targets in the target group using the protocol and port that you specify when configuring routing and performs health checks on the targets using these health check settings.

Routing is performed independently for each target group, even when a target is registered with multiple target groups.

Note that you can configure listener rules to route requests to different target groups based on the content of the application traffic.

The continuation of ALB will be discussed on my next blog.

Thanks,

Bharathi.

--

--

Bharathi Batthula

Bharathi is a self driven and purpose-oriented person.The main mission is to create profound change in her career. contact her on bharathi.batthula6@gmail.com