0% found this document useful (0 votes)
68 views18 pages

Application Load Balancer With AWS EC2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views18 pages

Application Load Balancer With AWS EC2

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Day 41: Setting up an Application Load Balancer with AWS EC2

Maninder Singh

Dear Learners, In Previous articles we will learn the AWS basics & IAM. In today article we will learn the Load Balancing with AWS EC2.

Definition Load Balancing?

Load balancing is the distribution of workloads across multiple servers to ensure consistent and optimal resources utilisation. It is an essential aspect of
any large-scale computing system. It helps you to improve the reliability and performance of your applications.

Elastic Load Balancing:

ELB (Elastic load balancing) is a service provided by Amazon web services that automatically distributes incoming traffic across multiple Ec2 instances.
ELB provides 3 types of load balancer.
Application Load balancer Diagram.

A) Application Load Balancer (ALB) :

It works and operates at layer 7 of the OSI model and is ideal for applications that require advanced routing and microservices.

B) Network Load Balancer (NLB):

Operates at layer 4 of the OSI model and is ideal for application that requires high throughput and low latency.

C) Classic Load Balancer (CLB):

operates at layer 4 of the OSI model and is ideal for application that require basic load balancing features.

Discuss with the help of one Practical:

Task1:

launch 2 Ec2 instances with an Ubuntu AMI and user user data to install the Apache web Server.

Log in to your AWS Console and go to the Ec2 dashboard.

Click on the "Launch instance" button and select "ubuntu server"


Launch instance" button and select "ubuntu Diagram.

Choose the instance type,configure the instance details,add storage and configure security groups as required.
add storage and configure security groups as required Diagram.

Add Details security groups Diagrams.


In the "Configuration instance details" scroll down to the "Advanced Details" section and expand the "user data field.

In the "user data" field enter the following commands to install and start the "Apache web server"

I will share the commands for user data field:

#!/bin/bash

sudo apt-get update -y

sudo apt-get install apache2 -y

sudo systemctl start apache2

sudo systemctl enable apache2

User data option Script Diagram.

You can see 2 instances are created and running.

first one name is (Apache-server1)

Second name is (Apache-server2)

You can see 2 instances are created and running Diagram

After creating the both instances you can modify the index.html file. (Path is sudo nano /var/www/index.html). it will display your name also do it for 2
instances which include "Train with shubham community is super Awesome:".

For apache-server1

Check the apache2 status using the below command:

Syntax:- sudo systemctl status apache2

sudo systemctl status apache2 Diagram.

Go inside the /var/www/html path and edit index.html file


Inside the var/www/html file Diagram.

See the syntax of var/www/html file diagram.

copy the public ip address of your Ec2 instances.

open a web browser and paste the public IP address into the address bar.

you should see a webpage displaying information about your PHP installation.

Public ip copy and open see apache file is open diagram,

For apache2 status.

Go inside /var/www/html path and edit index.html file.

sudo systemctl status apache2 for Server 2 Diagram,

html file syntax Diagram.

copy the public ip address of your Ec2 instances.

open a web browser and paste the public IP address into the address bar.

you should see a webpage displaying information about your PHP installation.
copy the public ip address of your Ec2 instances for Server 2 Diagram.

Task2:

Create an Application Load Balancer (ALB) in EC2 using the AWS Management Console.

Log in to the AWS Management Console and go to the EC2 dashboard.

Click on "Load Balancers" in the left side navigation menu and then click the "Create Load Balancer" button.
Click on "Load Balancers" in the left side navigation menu Diagram,

Select "Application Load Balancer" as the load balancer type and click "create"
Select "Application Load Balancer Diagram.

Now Configure the load balancer as per your need such as listener,security group and availability zones. For the listener you can choose HTTP or HTTPS
depending on your application's requirements.
Provide a name to your Application load balancer Diagram.

Configure the VPC and Avaliablity Zone Diagram,

Configure the Security Groups Diagram.

Create a target group by specifying a name,protocol,port,and health check settings. choose the same availability zones as the load balancer and select the
instances that you launched in Task-1 as targets for the target group.
targets for the target group Diagram

Add Ec2 instances which you launch in task-1 to the ALB as target groups.
Add Ec2 instances which you launch in task-1 to the ALB as target groups Diagram.

Add Ec2 instances which you launch in task-1 to the ALB as target groups Register create diagram.

Review option:-
Create Diagram.

Load balancer is created.


Load balancer is created Diagram.

Target group is created.


Target group is created Diagram,

Now its time to verify the ALB is working properly by checking the health status option of the target instances and testing the load balancing capabilities.

Verify that the instances are registered with the load balancer by checking the target group health status. you should see a healthy status for all the
instances in the group.
healthy status for all the instances in the group Diagram.

Testing the load balancer capabilities by accessing the load balancer DNS name in web browser. you should see the traffic is being envely distribution
across the both instances.

Copy the DNS name and hit it into the browser one by one.

Copy the DNS name and hit it into the browser one by one Diagram.
Apache server1
Apache server 1 Diagram.

In this blog, I have discussed AWS Ec2 Load Balancer with the help of task how we can manage(balance) our Application load between 2 Servers. If you
have any questions or would like to share your experiences, feel free to contact me or leave a comment.

Thank you for reading !! I hope you find this article helpful!!

Happy Learning !!

Next Topic:

Day 42: IAM Programmatic access and AWS CLI

You might also like