๐ AWS Application Load Balancer with Auto Scaling (Real-World Project)
๐ Project Overview
This project demonstrates a real-world, production-style AWS architecture where a web application runs securely on private EC2 instances behind an Application Load Balancer (ALB) with Auto Scaling Group (ASG).
The infrastructure is designed following AWS best practices for:
- ๐ Security
- ๐ Scalability
- ๐ High Availability
๐๏ธ Architecture Diagram (Logical Flow)
User
โ
Application Load Balancer (Public Subnet)
โ
Target Group
โ
Auto Scaling Group
โ
Private EC2 Instances (Apache Web Server)
โ
NAT Gateway โ Internet (Outbound Only)
๐งฐ AWS Services Used
- Amazon VPC
- Amazon EC2 (Ubuntu)
- Application Load Balancer (ALB)
- Auto Scโฆ
๐ AWS Application Load Balancer with Auto Scaling (Real-World Project)
๐ Project Overview
This project demonstrates a real-world, production-style AWS architecture where a web application runs securely on private EC2 instances behind an Application Load Balancer (ALB) with Auto Scaling Group (ASG).
The infrastructure is designed following AWS best practices for:
- ๐ Security
- ๐ Scalability
- ๐ High Availability
๐๏ธ Architecture Diagram (Logical Flow)
User
โ
Application Load Balancer (Public Subnet)
โ
Target Group
โ
Auto Scaling Group
โ
Private EC2 Instances (Apache Web Server)
โ
NAT Gateway โ Internet (Outbound Only)
๐งฐ AWS Services Used
- Amazon VPC
- Amazon EC2 (Ubuntu)
- Application Load Balancer (ALB)
- Auto Scaling Group (ASG)
- Target Groups
- NAT Gateway
- Internet Gateway
- Security Groups
โ๏ธ Key Features
โ EC2 instances run in private subnets (no public IP) โ Internet access only through ALB โ Outbound internet via NAT Gateway โ Auto Scaling based on demand โ Highly available across multiple AZs
๐ช Step-by-Step Implementation
1๏ธโฃ VPC Creation
- Custom VPC with CIDR:
10.0.0.0/16
2๏ธโฃ Subnets
- Public Subnets โ ALB & NAT Gateway
- Private Subnets โ EC2 instances
3๏ธโฃ Internet Gateway
- Attached to VPC for inbound internet traffic
4๏ธโฃ NAT Gateway
- Created in public subnet
- Enables outbound internet for private EC2
5๏ธโฃ Security Groups
ALB Security Group
- Allow HTTP (80) from
0.0.0.0/0
EC2 Security Group
- Allow HTTP (80) only from ALB SG
6๏ธโฃ Launch Template
- Ubuntu AMI
- Apache installed using User Data script
7๏ธโฃ Target Group
- Target type: Instance
- Protocol: HTTP (80)
- Health check path:
/
8๏ธโฃ Application Load Balancer
- Internet-facing
- Listener on port 80
- Attached to target group
9๏ธโฃ Auto Scaling Group
- Min: 1
- Desired: 2
- Max: 3
- Integrated with ALB
๐ User Data Script (Ubuntu EC2)
#!/bin/bash
apt update -y
apt install -y apache2
systemctl start apache2
systemctl enable apache2
echo "<h1>AWS ALB + Auto Scaling Web Server</h1><h2>Hostname: $(hostname)</h2>" > /var/www/html/index.html
๐งช Verification Steps
- Copy ALB DNS name
- Open browser:
http://<ALB-DNS-NAME>
- Refresh page multiple times
- Observe different hostnames (load balancing working)
โ Final Outcome
โ Secure architecture with no public EC2 IPs โ Load balancing across multiple instances โ Auto scaling handles traffic automatically โ Production-grade AWS setup
๐ง Key Learnings
- Designing secure AWS VPC architecture
- Load balancing & auto scaling concepts
- Real-world cloud networking
- Hands-on AWS infrastructure deployment
๐ Use Cases
- Enterprise web applications
- Microservices backend
- Scalable production workloads
๐จโ๐ป Author
Irfan Pasha Cloud Engineer | AWS Enthusiast
๐ GitHub:https://github.com/yourusername ๐ DEV: https://dev.to/yourusername
โญ If you found this project helpful, please give it a star!