Application Load Balancer in AWS

Rishikesh Varvade
5 min readFeb 16, 2021

Elastic Load Balancing automatically distributes incoming application traffic across multiple targets, such as Amazon EC2 instances, containers, IP addresses, Lambda functions, and virtual appliances. It can handle the varying load of your application traffic in a single Availability Zone or across multiple Availability Zones.

There are four types of load balancers offered by Elastic Load Balancer which are as follows:

  • Classic Load Balancer
  • Application Load Balancer
  • Network Load Balancer
  • Gateway Load Balancer

In this article, we will be focusing on Application Load Balancer.

What is an Application Load Balancer?

Application Load Balancer operates at the request level (layer 7) of theOSI model, routing traffic to targets (EC2 instances, containers, IP addresses, and Lambda functions) based on the content of the request. Ideal for advanced load balancing of HTTP and HTTPS traffic, Application Load Balancer provides advanced request routing targeted at the delivery of modern application architectures, including microservices and container-based applications.

Components of Application Load Balancer

  • A load balancer is used to distributes incoming application traffic across multiple targets.
  • A listener is used to check the connection request from clients, using the protocol and port that you configure.
  • Each target group routes requests to one or more registered targets, such as EC2 instances, using the protocol and port number that you specify. You can register a target with multiple target groups.
  • Health checks are performed on all targets registered to a target group that is specified in a listener rule for your load balancer. You can configure health checks on a per target group basis.

Now let’s have a look at how to setup an Application Load Balancer using AWS console.

First login to AWS console and navigate to EC2. In the navigation pane, click ‘Load Balancer’ and click ‘Create Load Balancer’.

Create Load Balancer in AWS Console

Now you will get the following options to choose as your load balancer. We will choose the application load balancer and click ‘create’.

Selecting the load balancer type

There is one more option for a classic load balancer when you scroll down.

Now, let’s configure the load balancer with the following settings.

  • Name: Name of your load balancer
  • Scheme: An Internet-facing load balancer routes requests from clients over the Internet to targets. An internal load balancer routes requests from clients to targets using private IP addresses.
  • IP address type: The IP addresses used by your subnets, either IPv4 (ipv4) or IPv4 and IPv6 (dual-stack).
Configure Load Balancer

Now configure the listeners and select VPC and at least two subnets and click ‘Next: Configure Security Settings’.

Note: In a VPC, we need at least two subnets, this improves the availability of your load balancer.

Now create a security group and add rules according to your needs. We need a load balancer to manage HTTP traffic for our web application. So we will keep port 80 open from anywhere.

Configure Security Groups for Load Balancer

Next, we need to configure routing.

  • Target Group: New target group of using the existing target group. Remember that you can always create a target group first and then create the load balancer and vice versa.
  • Name: Name of the target group
  • Target type: On what target you want your load balancer to work on.
  • Protocol: HTTP or HTTPS
  • Port: The port the load balancer uses when routing traffic to targets in this target group (1–65535).
  • Protocol version
Configure Routing for Load Balancer

Now we specify the protocol load balancer uses and destination path on which we want to perform the health checks. You get some advanced settings in which you can modify some values of the health check.

  • Port: The port the load balancer uses when performing health checks on targets.
  • Healthy threshold: The number of consecutive health check successes required before considering an unhealthy target healthy (2–10).
  • Unhealthy threshold: The number of consecutive health check failures required before considering a target unhealthy (2–10).
  • Timeout: The amount of time, in seconds, during which no response means a failed health check (2–120 seconds)
  • Interval: The approximate amount of time between health checks of an individual target (5–300 seconds).
  • Success codes: The HTTP codes to use when checking for a successful response from a target. You can specify multiple values (for example, “200,202”) or a range of values (for example, “200–299”).

Click on ‘Next: Register Targets’. Now select the instances in which your web application resides and you wish to perform load balancing on it.

Registering Targets

Finally, review the configurations and click on ‘Create’.

Final review before launching the Load Balancer

After the successful creation of a load balancer, you will be able to see a load balancer and a target group created. Your load balancer will be assigned with a DNS name which can be used to redirect to your web application to distribute traffic to multiple targets if your target is healthy and passes the health checks.

DNS Name in the Load Balancer Dashboard

I hope that this article helped you to understand the application load balancer and how to create one using AWS console.

Happy Clouding!

--

--