Skip to main content

Command Palette

Search for a command to run...

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

Published
3 min read
Day 41: Setting up an Application Load Balancer with AWS EC2 🚀 ☁
A

"I'm a 3rd-year Computer Engineering student at Marwadi University with skills in C++, web development (MERN stack), and DevOps tools like Kubernetes. I contribute to open-source projects and share tech knowledge on GitHub and LinkedIn. I'm learning cloud technologies and app deployment. As an Internshala Student Partner, I help others find jobs and courses." now currently focusing on #90DaysOfDevops

LB2

Hi, I hope you had a great day yesterday learning about the launch template and instances in EC2. Today, we are going to dive into one of the most important concepts in EC2: Load Balancing.

What is Load Balancing?

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

Elastic Load Balancing:

Elastic Load Balancing (ELB) is a service provided by Amazon Web Services (AWS) that automatically distributes incoming traffic across multiple EC2 instances. ELB provides three types of load balancers:

Read more from here

  1. Application Load Balancer (ALB) - operates at layer 7 of the OSI model and is ideal for applications that require advanced routing and microservices.
  • Read more from here
  1. Network Load Balancer (NLB) - operates at layer 4 of the OSI model and is ideal for applications that require high throughput and low latency.
  • Read more from here
  1. Classic Load Balancer (CLB) - operates at layer 4 of the OSI model and is ideal for applications that require basic load balancing features.

🎯 Today's Tasks:

Task 1:

  • launch 2 EC2 instances with an Ubuntu AMI and use User Data to install the Apache Web Server.

  • Modify the index.html file to include your name so that when your Apache server is hosted, it will display your name also do it for 2nd instance which include " TrainWithShubham Community is Super Aweasome :) ".

  • 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.

Task 2:

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

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

  • Verify that the ALB is working properly by checking the health status of the target instances and testing the load balancing capabilities.

LoadBalancer

Let’s begin with task 1 :

  1. Log in to AWS Console and navigate to EC2.

  2. Launch two EC2 instances with the following settings (Name:- Apache-1,Apache-2):

    • AMI: Ubuntu

    • Instance Type: t2.micro

    • Network Settings: Allow HTTP and HTTPS traffic

  3. Configure User Data to install Apache using advanced detail and customize the index.html file.

#!/bin/bash
sudo apt-get update -y
sudo apt-get install apache2 -y
sudo systemctl start apache2
sudo systemctl enable apache2

  1. Modify index.html on each server to display different content.

  2. Access the public IP addresses of the instances to verify Apache installation.

Let’s begin with task 2:

Steps:

  1. Navigate to Load Balancers in the AWS Management Console.

    Click on create load balancer

  2. Create an Application Load Balancer:

    • Name: php-load-balancer

    • Scheme: Internet Facing

    • IP Address Type: IPv4

    • Network Mapping: Select at least two AZs.

    • Security Group: Choose the required security groups.

  3. Create Target Groups and register your EC2 instances.

    • Now click on Create load balancer

  1. Test the ALB by accessing its DNS name. Verify that traffic is distributed between your instances.

Thankyou for reading !!!!!

90DaysOfDevops

Part 5 of 49

So In This Series I am following 90 DaysOfDevops challenge , what i will learn in my devops journey i will share with you with my blogs ,You will get blog on tools which used by devops engineer , example :- Linux,ansible,terraform,docker,etc

Up next

Day 40 : AWS EC2 Automation ☁

Automation in EC2: Amazon EC2 or Amazon Elastic Compute Cloud can give you secure, reliable, high-performance, and cost-effective computing infrastructure to meet demanding business needs. Also, if you know a few things, you can automate many things....

More from this blog

A

Anand Raval

118 posts

Hello I am Anand Raval , i contributed my work in robotics(arduino uno) , fronted web devloper,competitive programming, now currently focusing on #90DaysOfDevops