Skip to content

This is my AWS project where I set up an Application Load Balancer with three Auto Scaling Groups (Home, Mobile, Laptop) using static, scheduled, and dynamic scaling to learn how scaling and load balancing work in real time.

Notifications You must be signed in to change notification settings

Devyani1430/Application-Loadbalancer-and-Autoscalling-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

LoadBalancer and Autoscalling Group

Introduction

In this project, I implemented an Application Load Balancer (ALB) and configured Auto Scaling Groups (ASG)(Static , Dynamic , Sceduled) to handle traffic distribution and scaling of EC2 instances.

The setup ensures high availability, fault tolerance, and scalability by distributing incoming requests across multiple instances and automatically adjusting capacity based on demand.

I have created 3 autoscalling groups named as Home (static), Mobile (Sceduled) and Laptop(Dynamic). Each Auto scalling group is connected to its traget group and further the target groups are connected to Application LoadBalancer

Architecture Diagram

Project Flow

Features Implemented

  • Application LoadBalancer

    • Distributes incoming traffic across multiple target groups.
    • Ensures better fault tolerance and high availability.
  • AutoScalling Groups
    I created three different ASGs to demonstrate scaling strategies :

    1. Home (Static Scaling) → Fixed number of instances.

    2. Mobile (Scheduled Scaling) → Scales based on pre-defined schedule (e.g., scale out during peak hours).

    3. Laptop (Dynamic Scaling) → Scales in/out automatically based on CPU Utilization.

  • Target Groups

    • Each Auto Scaling Group is attached to its respective target group.

    • Target groups are connected to the Application Load Balancer for routing requests.

Steps

1. Launch Template

Launch 3 Templates : Home , Mobile and laptop with diffrent user data script.

  • Go to Launch Template click on create template
  • Name your template
  • Write Discription

launch template

  • Select AMI from Quick Start (I choosed Amazon Linux)
    You can choose your own AMI if u have created one.

chooseAMI

  • Select Instance Type
  • Select Keypair

selectKeyPair

  • Select Network Settings. here my application is simple so i only need port 80 and port 22. you can select existing security group too.

NetworkSetting

  • add user datascript in advanced options. (you don't need to add this script if u hae selected your own AMI )

  • click on create template

Userscript

  • Similarly Create other templates for Mobile and Laptop

User datascript for mobile :

#!/bin/bash   
sudo yum update -y  
sudo yum install -y httpd  
sudo systemctl start httpd  
sudo systemctl enable httpd

sudo mkdir /var/www/html/mobile
echo "<h1>This is the mobile page $(hostname -f)</h1>" >
/var/www/html/mobile/index.html

User datascript for laptop :

#!/bin/bash   
sudo yum update -y  
sudo yum install -y httpd  
sudo systemctl start httpd  
sudo systemctl enable httpd

sudo mkdir /var/www/html/laptop
echo "<h1>This is the laptop page $(hostname -f)</h1>" >
/var/www/html/laptop/index.html

2. Creating AutoScalling Group (ASG)

Let's Start with creating ASG for mobile. It is a Sceduled ASG.

  • Go to Autoscalling Group and click on create autoscalling.

(You will see the 7 steps on lefthand side of the screen)

  1. Choose Launch Template
    • Give Name to autoscalling group.
    • Select a Launch Template of mobile for mobile autoscalling group.

autoscalling

  • click on next...go to next step..

autoscalling

  1. Choose instance launch option
    • Select Availability Zone. (Atleast 2)
    • go to next step..

autoscalling autoscalling

  1. Integrate with other services

We are going to integrate these ASG with Loadbalancer after creating all 3 ASG. So for now let's go to next step..

autoscalling

  1. Configure Group size and scalling
  • Here for mobile we are giving : Desired = 3 , min = 2 , max = 7. (After creating mobile ASG we will make it sceduled)

    For Laptop (Dynamic) ASG select : Desired = 3 , min = 2 , max = 7.

    For Home (static) ASG select : Desired = 2 , min = 2 , max = 2.

autoscalling

  • select target tracking scaling policy
    ( if your ASG is static you don't need policy so select No scaling policy )
  • select metric type - Here i choose CPU utiliztion.
  • select target value - I choose 50.
  • select instacnce warmup - i choose 300 sec i.e, 5 min.
  • go to next step..

autoscalling

  1. Add notification
  2. Add tags

you dont have to do anything in step 5 and 6 so just click on next.

autoscalling

  1. Review
    • select create autoscaling group

autoscalling

Similarly create other 2 ASG according to their type static and dynamic. Just need to change the group size as i mentioned. autoscalling

Now to make Mobile ASG Sceduled follow following steps :

  • Click on Mobile ASG...(You will see the following interface)

autoscalling

  • Scroll down to bottom..
  • Click on Create schedule action..

autoscalling

  • Give name to your schedule.
  • Enter Desired , min and max values of instances.
  • Choose Cron option in recurrence and give specific time in side box ( sequence is - minute hour date month and day of week)

autoscalling

  • Enter the ending time with date
  • click on Create

autoscalling

  • If you click on mobile ASG and scroll doen to Sceduled Action you will see the the Created scheduled action.

3. Creating Target Group For each Autoscalling Group

  • Go to Target Groups Click on Create Target Group

targetgroup

  • Give a Name to your Target Group.

targetgroup

  • Scroll down and go to health check section.
  • Give a path of your application in Health Check Path section.

[Note : i Gave "/" as a path . Here "/ " represten the directry " /var/www/html/ " which is defualt directry of httpd]

  • Go to next step.

targetgroup

  • Click on Create Traget Group (don't need to change anything else)

targetgroup

-Similarly Create Target Groups for Laptop and Mobile.

  • You only need to change the path in Health check section as given.

For Laptop :

targetgroup targetgroup

For Mobile :

targetgroup targetgroup

  • The 3 Target Groups are created.

targetgroup

4. Connecting Autoscalling group to Target Goups

  • Select an Autoscalling Group .
  • Click on Action at top right corner.
  • Click on Edit

ASG-Targetgroup

  • Scroll down and you will see the Load balancing section.
  • Select a Target group for autoscalling group we selected.
    (for laptop ASG select Lptop target group, for mobile ASG select Mobile Target group.)

ASG-Targetgroup

ASG-Targetgroup

  • Enter Cooldown time and click on update.

  • Successfully connected the Autoscalling group and target groups.

  • Repeat process to connect each autoscalling group to its target group.

ASG-Targetgroup

5. Creating Application Load Balancer and Connecting to Target Groups.

  • Go to Load Balancers and Click on Create Load Balancer

loadblancer

  • Select Application Load Balancer. Click on Create

loadblancer

  • Give name to the loadbalancer.
  • Select Internet facing option

loadblancer

  • In Network Mapping section , Select Availability Zones atleast 2.
    (choose AZ same as the AZ we selected while creating autoscalling group.)

loadbalancer

  • In Security Group section , select a existing security group.

(Select same security group we selected while creating autoscalling group)

loadbalancer

  • In Listners and Routing section
    • select forward to target group
    • Choose a default target group. (Here default target group is HomeTG)
    • no need to change port n protocol.
    • Click on Create Load Balancer

loadbalncer

loadbalncer

  • Successfully created Application loadbalancer.

loadbalncer

  • If you scroll down , you will see the HomeTG as defualt target group in Listners and Rules section.

loadbalncer

  • To add other Target groups..
    • select HTTP80 i.e., HomeTG
    • Click on Manage Rules
    • Click on Add Rule

loadbalncer

  • Give name to rule.
  • In condition section , click on Add condition

loadbalncer

  • Give path for mobile application..

loadbalncer

  • In Actions section
    • select forward to target group
    • select the target group i.e., MobileTG
    • Go to next step..

loadbalncer

  • In Listners rule , give priority 1 for mobileTG
  • click on next

loadbalancer

  • Click on Add rule.

loadbalancer

  • Successfully connected Mobile Target Group to Loadbalancer

loadbalancer

  • Similarly connect Laptop target group to load balancer with priority 2.

loadbalancer loadbalancer loadbalancer loadbalancer

Now if you check in instance dashboard you will see the Active instances got created automatically.

result

To check if it is working properly

  • go to Load balacer.
  • click on the load balancer we created
  • scroll down and copy DNS name
  • search it through browser

DNSname

6. Results

  • The ALB DNS successfully routed traffic to all three target groups.
  • Scaling actions were verified:
    • Home ASG maintained fixed instances.
    • Mobile ASG scaled according to schedule.
    • Laptop ASG scaled dynamically on CPU utilization.
  • Application remained available across multiple Availability Zones.

result

result

result

Technologies Used

  • Amazon EC2 – Virtual servers to host the application.

  • Application Load Balancer (ALB) – For distributing incoming traffic across target groups.

  • Launch Templates

  • Auto Scaling Groups (ASG) – To implement different scaling strategies (Static, Dynamic, Scheduled).

  • Target Groups – For routing traffic to the right set of instances.

  • Amazon Linux – Operating system used for EC2 instances.

  • Security Groups – For controlling inbound and outbound traffic.

Conclusion

This project demonstrates how an Application Load Balancer (ALB) integrated with multiple Auto Scaling Groups (ASG) ensures high availability, fault tolerance, and scalability in AWS.

By implementing Static, Scheduled, and Dynamic Scaling, I gained hands-on experience in managing different scaling strategies. The setup successfully routed traffic across target groups, adjusted instance counts automatically, and handled application requests through a single DNS endpoint.

Overall, this project gave me a solid understanding of load balancing, scaling automation, and AWS infrastructure management.

About

This is my AWS project where I set up an Application Load Balancer with three Auto Scaling Groups (Home, Mobile, Laptop) using static, scheduled, and dynamic scaling to learn how scaling and load balancing work in real time.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published