TYPE ON THE FIELD BELOW AND PRESS ENTER TO SEARCH FOR BLOG POSTS

Elastic Load Balancer distributes incoming web traffic across multiple EC2 instances attached to it. This guide will walk you through setting up your first load balancer in AWS using Amazon Management Console.

Health checks can be configured in the load balancer so that the health of the attached EC2 instances can be monitored and the traffic can be routed only to healthy instances. The EC2 instances attached to the load balancer can also be setup across multiple availability zones so that even if the entire availability zone goes down, the load balancer can route traffic to instances in the healthy availability zone thereby increasing fault tolerance of your applications.

Two types of load balancers are supported: Application load balancers and Classic load balancers. Application load balancers provides advanced and improved features than Classic load balancers. Also Application load balancers support features like Host and Path based routing, routing to multiple ports on a single instance, HTTP/2, web sockets and deletion protection which is not supported by Classic load balancers. Cross zone load balancing which is distributing traffic evenly across registered instances in all enabled availability zones is enabled by default in an Application load balancer. You will be setting up an Application load balancer for this article.

The following steps have to be completed to create your first Application Load Balancer

  • Selecting the load balancer type
  • Configuring the load balancer and the listener
  • Configuring a Security group for the load balancer
  • Configuring a Target group
  • Register Targets with the target group
  • Creating and Testing the Load Balancer

Each availability zone that you have chosen must consist at least one registered EC2 instance to handle traffic. If the instances are launched inside a VPC, make sure that the VPC has at least one public subnet in each of the Availability zones. The Security group of the EC2 instances should allow HTTP access on port 80. Verify that the browser displays the default web page when the DNS name of the instance is accessed.

Selecting the load balancer type

For the sake of this article, we will go through the steps involved in creating an Application Load Balancer.

  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
  2. On the navigation bar, choose a region for your load balancer. Be sure to select the same region that you used for your EC2 instances.
  3. On the navigation pane, under LOAD BALANCING, choose Load Balancers.
  4. Choose Create Load Balancer.
  5. Choose Application Load Balancer, and then choose Continue.

Configuring the load balancer and the listener

The listener has to be a port number on which a service listens. Configuring port numbers which is not served by a service throws warnings that the instance is not healthy.

  1. For Name, type a name for your load balancer. The name of your Application Load Balancer must be unique within your set of Application Load Balancers for the region, can have a maximum of 32 characters, can contain only alphanumeric characters and hyphens, and must not begin or end with a hyphen.
  2. For Scheme, keep the default value, internet-facing.
  3. For IP address type, select ipv4 if your instances support IPv4 addresses or dualstack if they support IPv4 and IPv6 addresses.
  4. For Listeners, keep the default, which is a listener that accepts HTTP traffic on port 80.
  5. For Availability Zones, select the VPC that you used for your EC2 instances. For each of the two Availability Zones that contain your EC2 instances, select the Availability Zone and then select the public subnet for that Availability Zone.
  6. Choose Next: Configure Security Settings.
  7. For this article, you are not using a secure listener. Choose Next: Configure Security Groups.

Configuring a Security group for the load balancer

The security group of the load balancer must allow communication with the instances in the target group on both the health check port and the listener ports.

  1. Choose Create a new security group.
  2. Type a name and description for the security group, or keep the default name and description. This new security group contains a rule that allows traffic to the load balancer listener port that you selected on the Configure Load Balancer page.
  3. Choose Next: Configure Routing.

Configuring a Target group

The load balancer checks the health of targets in this target group using the health check settings defined for the target group. On the Configure Routing page, complete the following procedure.

  1. For Target group, keep the default, New target group.
  2. For Name, type a name for the new target group.
  3. Keep Protocol as HTTP and Port as 80.
  4. For Health checks, keep the default protocol and ping path.
  5. Choose Next: Register Targets.

Register Targets with the target group

To register targets with the target group

  1. For Instances, select one or more instances.
  2. Keep the default port, 80, and choose Add to registered.
  3. If you need to remove an instance that you selected, for Registered instances, select the instance and then choose Remove.
  4. When you have finished selecting instances, choose Next: Review.

Creating and Testing the Load Balancer

  1. On the Review page, choose Create.
  2. After you are notified that your load balancer was created successfully, choose Close.
  3. On the navigation pane, under LOAD BALANCING, choose Target Groups.
  4. Select the newly created target group.
  5. On the Targets tab, verify that your instances are ready. If the status of an instance is initial, it’s probably because the instance is still in the process of being registered, or it has not passed the minimum number of health checks to be considered healthy. After the status of at least one instance is healthy, you can test your load balancer.
  6. On the navigation pane, under LOAD BALANCING, choose Load Balancers.
  7. On the Description tab, copy the DNS name of the load balancer (for example, my-loadbalancer 1234567890.us-east-1.elb.amazonaws.com). Paste the DNS name into the address field of an Internet connected web browser. If everything is working, the browser displays the default page of your server.

You may have to modify the configuration of health checks depending on the application that is hosted in your targets.

You can now host your own application in the registered targets and serve them via the newly created Application Load Balancer. If your existing application is served via a Classic Load Balancer, we will learn about migrating your existing Classic Load Balancer to Application Load Balancer in the next article.

GSM Plus Infotech