Creating an Elastic Load Balancer in AWS

Elastic Load Balancing dynamically distributes and balances incoming application traffic across all of your operating instances, hence increasing your application's flexibility and reliability. This lesson walks you through the process of configuring Classic Load Balancers using the AWS Management Console, a web-based platform.

Create an Elastic Load Balancer (ELB)

Elastic Load Balancing automatically distributes and balances the incoming application traffic among all the instances you are running, thus improving the availability and scalability of your application. It seamlessly provides load balancing capacity. You create a load balancer and register instances with it which serves as a single point of contact for clients. The addition and deletion of EC2 instances from the load balancer can be done without disturbing the flow of information.

If the call completes successfully, a new load balancer is created with a unique Domain Name Service (DNS) name. The load balancer receives incoming traffic and routes it to the registered instances. You can create up to 20 load balancers per region per account. You can request an increase in the number of load balancers for your account.

The service also makes it easy to add new instances or remove under-used instances when you need to increase or decrease the capacity of your application. The following diagram shows how the load balancer works. In this diagram, the load balancer contains two listeners. By default, the load balancer is configured to listen to HTTP traffic on port 80. The first listener accepts traffic on port 80 using HTTP and forwards these requests to the Amazon EC2 instances using HTTP on port 8080. The other listener accepts traffic on port 443 using HTTPS and forwards these requests to the Amazon EC2 instances using HTTPS on port 4443.

load balancer

You can specify the protocol and port for both the client and the Amazon EC2 instances. In this step, we will create a load balancer for an HTTP service. We’ll specify that the load balancer listens on port 80 for incoming traffic from clients and then distribute traffic on port 80 to the instances.

As soon as your load balancer becomes available, you’re billed for each hour or partial hour that you keep the load balancer running. For more information about Elastic Load Balancing pricing, see the Elastic Load Balancing details page. For more information about elastic load balancers, go to the Elastic Load Balancing Documentation.

MindMajix YouTube Channel
           

Creating a Load Balancer

You can create an internal load balancer to distribute traffic to your EC2 instances in private subnets.

Load Balancer has two components: the load balancer and the controller service. The load balancer monitors traffic, whereas the controller service monitors load balancers.

If a call is finished, a new load balancer is created with a unique Domain Name Service (DNS). Almost 20 load balancers can be created per account which is also extendable.

1. Define a load balancer:

  • Open the Amazon EC2 console at https:// console.aws.amazon.com/ ec2/.
  • In the Navigation pane, in the Region list, click US East (Virginia).
  • In the Navigation pane, click Load balancers.
  • In the Create a new load balancer wizard, in the load balancers pane, click create load balancers.
  • On the define load balancer page, enter a name for your load balancer. In this example, type MyLB.
create a new load balancer
  • Leave the Listener Configuration set to the default value for this example. The Load Balancer Port and Protocol specify the port and protocol that the load balancer will use to listen for traffic from the clients. The Instance Protocol and Port specify the port and protocol the load balancer will use to route traffic to the instances. For example, if you want the load balancer to forward traffic to the instances using port 8080, you can specify that here.

Note: After you configure the listener information, you cannot change it. If you want to update this information, you will need to create a new load balancer.

  • Click Continue.
For an in-depth understanding and practical experience, Explore AWS Architect Training.

2. Configure the Health Check:

Elastic Load Balancing routinely checks the health of each load-balanced Amazon EC2 instance. This health check determines the instances of health status. If Elastic Load Balancing finds an unhealthy instance, it stops sending traffic to the instance and reroutes traffic to healthy instances.

a) On the Configure Health Check page of the Create a New Load Balancer wizard, do the following:

Create a New Load Balancer wizard

On the Configure Health Check page, under Configuration Options, do the following:

  • Leave Ping Protocol set to its default value of HTTP. In the future, if you want to use a more secure protocol for the load balancer to send ping requests to your instances, you can use HTTPS and specify a different port. For more information regarding HTTPS with Elastic Load Balancing, see Elastic Load Balancing Security Features in Elastic Load Balancing Developer Guide.
  • Leave Ping, Port set to its default value of 80. Elastic Load Balancing uses the ping port to send health check queries to your Amazon EC2 instances.

Note: If you specify a ping port value, your Amazon EC2 instances must accept incoming traffic on the port that you specify. You can set a port value other than 80, and you can change this value at any time.

  • In the Ping Path box, replace the default value with a single forward-slash (“/”).

Elastic Load Balancing sends health check queries to the ping path you specify. This example uses a single forward slash so that Elastic Load Balancing sends the query to your HTTP server’s default home page, whether that default page is named index.html, default.html, or any other different name. When you deploy your application, consider creating a special lightweight file that responds only to the health check. Doing so helps differentiate between traffic that is hitting your site and responses to the load balancer.

Related page: How To Launch Amazon EC2 Instances Using Auto Scaling

b) On the Configure Health Check page, under Advanced Options, set the Healthy Threshold to 2. Accept the default values on the other options.

Typically, the default value of 10 is fine for a healthy threshold. To expedite this tutorial, we specify 2, so you don’t have to wait as long to see healthy instances.

c) Click Continue.

3. Add Amazon EC2 instances:

  • On the Add EC2 Instances page, click Continue.
Add Amazon EC2 instances
  • Review your settings. To make changes to the settings, click the edit link for a specific step in the process.
Add Amazon EC2 instances_2

Note: After you create a load balancer, you can modify any of the settings except for Load Balancer Name and Port Configuration. To rename a load balancer or to change its port configuration, create a replacement load balancer.

  • Click Create.
  • On the Confirmation page, click Close.
Confirmation page

The confirmation window closes, returning you to the Load Balancers page. Your new load balancer now appears in the list.

As a best practice, you should have sufficient instances across Availability Zones to survive the loss of anyone Availability Zone. Therefore, we will ensure that our load balancer points to multiple Availability Zones in the next step.

Related Page: Clean Up Process In AWS

4. Record the Public DNS Address:

  • In the Load Balancers pane, click MyLB.
  • Click the Description tab.
Record the public DNS address
  • Write down the public DNS address. You will need it later in this tutorial.

5. Add an Availability Zone:

  • In the Load Balancers pane, click MyLB.
  • Click the Instances tab.
  • Click the plus icon.
Add an Availability Zone
  • In the Add and Remove Availability Zones dialog box do the following:

Click us-east-1b: 0 instances.

Click us-east-1c: 0 instances.

Click Save.

Add and Remove Availability Zones

In a later task, you will launch instances in these two Availability Zones by using Auto Scaling. You’ll see that the Availability Zones column for the load balancer is updated for both Availability Zones.

Related Page: Creating A Custom AMI In AWS

Advantages of using Load Balancing:

Elastic Load Balancing automatically distributes incoming application traffic across multiple Amazon EC2 instances in THE CLOUD. It enables you to achieve greater levels of fault tolerance in your applications, seamlessly providing the required amount of load balancing capacity needed to distribute application traffic. Its most important benefits are available, secure, and elastic.

  • Distribution of requests to EC2 instances in multiple availability zones
  • Hazard of overloading of instances is minimized
  • Continuous monitoring of health instances
  • Support for the sticky session feature
  • Support for end-to-end traffic encryption.

When You’re At

Here’s where you are while building your architecture.

MyLB

In the process of Launching an Instance, you set a security group to allow all traffic to connect to your Amazon EC2 instance via port 80 (HTTP). Now that you have created an Elastic Load Balancer, you can update your security group to allow only incoming HTTP traffic from your Elastic Load Balancer. Move on to further post Update Your Amazon EC2 Security Group.

List Of AWS Courses Offered By Mindmajix:

 AWS Certified SysOps AdministratorAWS Certified Solutions Architect / Professional
AWS Certified DeveloperAWS Certified DevOps Engineer
AWS Technical EssentialsAWS Database Migration Service
 AWS Lambda 2016and many more...

If you interested to learn AWS and building a career in Cloud Computing?  Then check out our AWS Certification Training Course at your near Cities

AWS Course in Ahmedabad, AWS Course  in Bangalore  AWS Course in Chennai,  AWS Course in Delhi, AWS Course in Dallas, AWS Course in Hyderabad, AWS Course in London, AWS Course in Mumbai, AWS Course in NewYork, AWS Course in Pune

These courses are incorporated with Live instructor-led training, Industry Use cases, and hands-on live projects. This training program will make you an expert in AWS and help you to achieve your dream job.

Job Support Program

Online Work Support for your on-job roles.

jobservice

Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:

  • Pay Per Hour
  • Pay Per Week
  • Monthly
Learn MoreGet Job Support
Course Schedule
NameDates
AWS TrainingNov 23 to Dec 08View Details
AWS TrainingNov 26 to Dec 11View Details
AWS TrainingNov 30 to Dec 15View Details
AWS TrainingDec 03 to Dec 18View Details
Last updated: 28 Sep 2024
About Author

Prasanthi is an expert writer in MongoDB, and has written for various reputable online and print publications. At present, she is working for MindMajix, and writes content not only on MongoDB, but also on Sharepoint, Uipath, and AWS.

read less
  1. Share:
AWS Articles