
Deploy a Multi-Tier Web App on AWS
Learn how to deploy a secure multi-tier web application on AWS using VPC, ALB, EC2 Auto Scaling, and Amazon RDS with step-by-step guidance.
Introduction -
Modern web applications require more than a single virtual machine. They need scalability, high availability, and secure communication between application and database layers.
In this project, I built a production-inspired multi-tier architecture on AWS using a custom VPC, Application Load Balancer, EC2 Auto Scaling, and Amazon RDS for MySQL. The goal was to separate the web and database tiers while allowing the infrastructure to automatically distribute traffic and recover from instance failures.

Why a Multi-Tier Architecture?
A multi-tier architecture separates different components of an application into independent layers.
Benefits include:
Better security
High availability
Easier scaling
Improved fault tolerance
Simplified maintenance
Instead of exposing the database directly to the internet, only the web servers communicate with Amazon RDS, while users access the application through an Application Load Balancer.
Architecture Overview -
The architecture consists of:
Custom Amazon VPC
Two public subnets
Two private database subnets
Internet Gateway
Application Load Balancer
Target Group
Launch Template
Auto Scaling Group
EC2 Web Servers
Amazon RDS MySQL
Building the Solution -
Configure the Network:
I created a custom VPC with four subnets:
Two public subnets for the web tier
Two private subnets for the database tier
The public subnets were associated with a route table connected to an Internet Gateway, while the private subnets remained isolated.





Configure Security Groups:
Three security groups were created:
ALB Security Group
EC2 Security Group
RDS Security Group
Traffic flows only through the intended layers:
Internet
↓
ALB
↓
EC2
↓
Amazon RDS
This approach follows the principle of least privilege by allowing only the required communication between resources.



Deploy Amazon RDS :
Next, I provisioned an Amazon RDS MySQL database inside the private subnets using a dedicated DB subnet group.
The database is not publicly accessible and accepts connections only from the EC2 security group.


Launch the Web Tier:
A Launch Template was created to standardize EC2 deployments.
Using EC2 User Data, each instance automatically:
Installed Apache
Installed PHP
Installed MySQL client libraries
Connected to Amazon RDS
Displayed instance metadata on the application page

Configure Load Balancing:
The Application Load Balancer distributes incoming HTTP requests across healthy EC2 instances.
A Target Group continuously performs health checks to ensure traffic is sent only to healthy servers.


Enable Auto Scaling:
The Auto Scaling Group maintains two running web servers across two Availability Zones.
Configuration:
Minimum instances: 2
Desired instances: 2
Maximum instances: 4
A target tracking policy scales the application when average CPU utilization exceeds 50%.

Testing the Deployment:
After deployment, both EC2 instances successfully registered with the Target Group and passed health checks.
Refreshing the Application Load Balancer DNS name demonstrated that traffic was being distributed between multiple web servers while maintaining database connectivity.



Key Takeaways:
This project demonstrates several AWS best practices:
Designing a custom VPC
Separating public and private application tiers
Restricting communication using security groups
Deploying Amazon RDS in private subnets
Automating EC2 provisioning with User Data
Distributing traffic using an Application Load Balancer
Scaling compute resources with Auto Scaling
Building a resilient multi-tier architecture
Cost Considerations:
The primary billable resources for this project are:
Amazon EC2 instances
Amazon RDS
Application Load Balancer
Amazon EBS storage
Public IPv4 addresses
Data transfer
Conclusion:
This project demonstrates how core AWS networking, compute, database, and load balancing services can be combined to build a secure and scalable multi-tier web application. While the application itself is simple, the architecture reflects patterns commonly used in production environments and provides a strong foundation for more advanced cloud-native deployments.
GitHub Repository:
The complete source code, deployment scripts, documentation, and screenshots for this project are available on GitHub.
Resources:
- Amazon VPC Documentation: https://docs.aws.amazon.com/vpc/
- Application Load Balancer Documentation: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/
- Amazon EC2 Auto Scaling Documentation: https://docs.aws.amazon.com/autoscaling/ec2/
- Amazon RDS Documentation: https://docs.aws.amazon.com/AmazonRDS/
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article