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
-
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 :-
Home (Static Scaling) → Fixed number of instances.
-
Mobile (Scheduled Scaling) → Scales based on pre-defined schedule (e.g., scale out during peak hours).
-
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.
-
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
- Select AMI from Quick Start (I choosed Amazon Linux)
You can choose your own AMI if u have created one.
- Select Instance Type
- Select Keypair
- Select Network Settings. here my application is simple so i only need port 80 and port 22. you can select existing security group too.
-
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
- 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.htmlUser 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.htmlLet'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)
- Choose Launch Template
- Give Name to autoscalling group.
- Select a Launch Template of mobile for mobile autoscalling group.
- click on next...go to next step..
- Choose instance launch option
- Select Availability Zone. (Atleast 2)
- go to next step..
- 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..
- 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.
- 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..
- Add notification
- Add tags
you dont have to do anything in step 5 and 6 so just click on next.
- Review
- select create autoscaling group
Similarly create other 2 ASG according to their type static and dynamic. Just need to change the group size as i mentioned.

Now to make Mobile ASG Sceduled follow following steps :
- Click on Mobile ASG...(You will see the following interface)
- Scroll down to bottom..
- Click on Create schedule action..
- 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)
- Enter the ending time with date
- click on Create
- If you click on mobile ASG and scroll doen to Sceduled Action you will see the the Created scheduled action.
- Go to Target Groups Click on Create Target Group
- Give a Name to your Target Group.
- 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.
- Click on Create Traget Group (don't need to change anything else)
-Similarly Create Target Groups for Laptop and Mobile.
- You only need to change the path in Health check section as given.
For Laptop :
For Mobile :
- The 3 Target Groups are created.
- Select an Autoscalling Group .
- Click on Action at top right corner.
- Click on Edit
- 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.)
-
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.
- Go to Load Balancers and Click on Create Load Balancer
- Select Application Load Balancer. Click on Create
- Give name to the loadbalancer.
- Select Internet facing option
- In Network Mapping section , Select Availability Zones atleast 2.
(choose AZ same as the AZ we selected while creating autoscalling group.)
- In Security Group section , select a existing security group.
(Select same security group we selected while creating autoscalling group)
- 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
- Successfully created Application loadbalancer.
- If you scroll down , you will see the HomeTG as defualt target group in Listners and Rules section.
- To add other Target groups..
- select HTTP80 i.e., HomeTG
- Click on Manage Rules
- Click on Add Rule
- Give name to rule.
- In condition section , click on Add condition
- Give path for mobile application..
- In Actions section
- select forward to target group
- select the target group i.e., MobileTG
- Go to next step..
- In Listners rule , give priority 1 for mobileTG
- click on next
- Click on Add rule.
- Successfully connected Mobile Target Group to Loadbalancer
- Similarly connect Laptop target group to load balancer with priority 2.
Now if you check in instance dashboard you will see the Active instances got created automatically.
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
- 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.
-
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.
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.
























































