
Building a Highly Available Web Application on AWS with Application Load Balancer & Auto Scaling
Designed and deployed a highly available web application on AWS using Amazon EC2, Application Load Balancer, and Auto Scaling Group. This project demonstrates how AWS services work together to improve availability, automate recovery, and distribute traffic across multiple Availability Zones.
Introduction
One of the key principles of cloud architecture is designing applications that continue serving users even when individual infrastructure components fail. While deploying a web application on a single Amazon EC2 instance is a common starting point, it introduces a single point of failure. If that instance becomes unavailable, the application becomes unavailable as well.
AWS addresses this challenge by providing services that distribute traffic, monitor application health, and automatically replace unhealthy resources.
In this project, I built a highly available web application using:
- Amazon EC2
- Application Load Balancer (ALB)
- Auto Scaling Group (ASG)
- Launch Template
- Target Group
- EC2 User Data
By the end of this project, I had:
- Two EC2 instances running across multiple Availability Zones
- An Application Load Balancer routing incoming traffic
- An Auto Scaling Group maintaining the desired capacity
- Automated Apache installation using EC2 User Data
Architecture Overview
The architecture consists of an internet-facing Application Load Balancer that distributes requests across multiple EC2 instances. A Target Group performs health checks, while an Auto Scaling Group ensures that healthy instances are always available.
Internet
│
▼
Application Load Balancer
│
Target Group (HTTP)
│
┌─────────────┴─────────────┐
▼ ▼
EC2 Instance 1 EC2 Instance 2
(Availability Zone A) (Availability Zone B)
│ │
└─────────────┬─────────────┘
│
Auto Scaling Group
│
Launch Template
Step 1 – Securing the Infrastructure
The first step was creating two security groups.
The Application Load Balancer Security Group allows HTTP traffic from the internet because it acts as the public entry point.
The EC2 Security Group allows:
- HTTP only from the ALB Security Group
- SSH only from my public IP address


This prevents users from accessing EC2 instances directly and ensures all web traffic passes through the load balancer.
Step 2 – Standardizing Deployments with a Launch Template
Instead of manually configuring each EC2 instance, I created a Launch Template.
The Launch Template stores:
- Amazon Linux 2023 AMI
- Instance type
- Storage configuration
- Security Groups
- Key Pair
- User Data script
Whenever the Auto Scaling Group launches a new instance, AWS automatically applies these settings.
This guarantees that every replacement server is configured consistently.

Step 3 – Automating Server Configuration
To eliminate manual setup, I used EC2 User Data.
When a new instance launches, AWS automatically executes the script, which:
- updates the operating system,
- installs Apache HTTP Server,
- starts and enables the Apache service,
- retrieves EC2 metadata using IMDSv2,
- generates a webpage displaying the Instance ID, Availability Zone, and Hostname.
This makes it easy to identify which EC2 instance is serving each request.
Step 4 – Configuring the Target Group
The Target Group acts as the bridge between the Application Load Balancer and the EC2 instances.
It continuously performs health checks and forwards traffic only to healthy targets.
Health Check Configuration:
- Protocol: HTTP
- Path: /
- Port: Traffic Port
Once both instances passed the health checks, they became eligible to receive incoming requests.

Step 5 – Deploying the Application Load Balancer
The Application Load Balancer became the public entry point for the application.
Instead of users connecting directly to EC2 instances, every request first reaches the ALB.
The ALB then:
- evaluates the Target Group,
- identifies healthy EC2 instances,
- distributes requests between them.
This improves both reliability and user experience.


Step 6 – Maintaining Availability with Auto Scaling
The Auto Scaling Group was configured with:
- Minimum Capacity: 2
- Desired Capacity: 2
- Maximum Capacity: 4
Although I did not configure dynamic scaling policies in this project, the Auto Scaling Group still provides automatic recovery.
If one EC2 instance becomes unhealthy, AWS launches a replacement using the Launch Template, helping maintain application availability.
Testing the Deployment
After deployment:
- both EC2 instances entered the Running state,
- the Target Group reported both instances as Healthy,
- the Application Load Balancer became Active.
Opening the ALB DNS name displayed the Apache webpage, including the EC2 Instance ID, Availability Zone, and Hostname.
Refreshing the page several times eventually showed a different Instance ID, confirming that requests were being distributed across multiple EC2 instances.



Key Takeaways
This project reinforced several important AWS concepts:
- Designing for high availability instead of relying on a single server
- Using Application Load Balancers to distribute traffic
- Performing health checks with Target Groups
- Standardizing EC2 deployments using Launch Templates
- Automating server configuration with EC2 User Data
- Using Auto Scaling Groups to improve resilience
The biggest takeaway was understanding how these services complement each other to create a more reliable and production-ready architecture.
Conclusion
High availability is a fundamental aspect of modern cloud applications. By combining Application Load Balancers, Target Groups, Launch Templates, Auto Scaling Groups, and EC2 User Data, it's possible to build infrastructure that is resilient, easier to manage, and better prepared to handle failures.
This project provided practical experience with one of the most common deployment patterns used on AWS and strengthened my understanding of designing cloud-native applications.
Source Code
The complete project, including documentation, User Data script, and screenshots, is available on GitHub:
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article