🚀 Deploying a Highly Available Web Application on AWS using ALB & Auto Scaling (Beginner-Friendly)

Published: (January 19, 2026 at 06:51 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

Introduction

In this hands‑on project, a production‑ready AWS architecture is built using core services such as VPC, Application Load Balancer (ALB), Auto Scaling Group (ASG), EC2, and NAT Gateway.

The setup follows AWS best practices:

  • Secure networking
  • High availability
  • Automatic scaling
  • No public access to EC2 instances

The guide is beginner‑friendly yet interview‑ready.

What You Will Learn

  • How to design a secure AWS VPC
  • Public vs. private subnets (real use‑case)
  • Application Load Balancer (ALB)
  • Auto Scaling Group (ASG)
  • NAT Gateway for outbound internet
  • Real‑world architecture used in companies

Architecture Overview

Internet
   |

Application Load Balancer (Public Subnets)
   |

Target Group
   |

Auto Scaling Group
   (EC2 Instances in Private Subnets)
   |

NAT Gateway → Internet (Outbound Only)
  • EC2 instances have no public IPs.
  • Only the ALB is exposed to the internet.

Services Used

  • Amazon VPC
  • EC2 (Ubuntu)
  • Application Load Balancer
  • Auto Scaling Group
  • Target Groups
  • NAT Gateway
  • Elastic IP
  • Security Groups

Step‑by‑Step Implementation

1️⃣ Create a Custom VPC

  • CIDR: 10.0.0.0/16
  • Enable DNS Hostnames and DNS Resolution

2️⃣ Create Subnets

Create four subnets:

Subnet TypeNamePurpose
PublicPublic‑Subnet‑1ALB
PublicPublic‑Subnet‑2NAT Gateway
PrivatePrivate‑Subnet‑1EC2
PrivatePrivate‑Subnet‑2EC2

Enable Auto‑assign Public IP = Yes only for the public subnets.

3️⃣ Internet Gateway

  • Create and attach an Internet Gateway to the VPC.
  • Required for ALB and NAT Gateway.

4️⃣ NAT Gateway (Critical)

  • Create a NAT Gateway in a public subnet.
  • Attach an Elastic IP.
  • Allows private EC2 instances to access the internet securely.

5️⃣ Route Tables

  • Public Route Table: 0.0.0.0/0 → Internet Gateway
  • Private Route Table: 0.0.0.0/0 → NAT Gateway

Associate each route table with the appropriate subnets.

6️⃣ Security Groups

  • ALB Security Group:

    • Inbound: HTTP (80) from 0.0.0.0/0
  • EC2 Security Group:

    • Inbound: HTTP (80) from ALB Security Group
    • Inbound (optional): SSH (22) from your IP

EC2 instances are reachable only via the ALB.

7️⃣ Launch Template (EC2)

  • AMI: Ubuntu 22.04
  • Instance Type: t2.micro

User Data Script

#!/bin/bash
apt update -y
apt install apache2 -y
systemctl start apache2
systemctl enable apache2
cat  /var/www/html/index.html
## Welcome from ALB + Auto Scaling
## Hostname: $(hostname)
EOF

8️⃣ Target Group

  • Target Type: Instance
  • Protocol: HTTP
  • Port: 80
  • Health Check Path: /

9️⃣ Application Load Balancer

  • Type: Internet‑facing
  • Subnets: Public subnets
  • Listener: HTTP 80 → forward to Target Group

🔟 Auto Scaling Group

  • Use the launch template created above.
  • Subnets: Private subnets
  • Desired Capacity: 2
  • Minimum: 1
  • Maximum: 3
  • Attach to the ALB target group.

Optional: Add a CPU‑based scaling policy.

Final Verification

  1. Copy the ALB DNS name.
  2. Paste it into a browser and refresh several times.

You should see different hostnames, confirming load balancing, auto scaling, and high availability.

GitHub Repository

Project source code & documentation:
https://github.com/IrfanPasha05/aws-alb-autoscaling-project

The repository includes:

  • Folder structure
  • User‑data scripts
  • Setup steps
  • Troubleshooting guide

Why This Project Matters

The architecture mirrors real production environments and is commonly used in:

  • Enterprise applications
  • DevOps & Cloud Engineer roles

It’s perfect for:

  • Resumes
  • Interviews
  • Portfolio (LinkedIn, DEV, etc.)

Future Enhancements

  • HTTPS with ACM
  • Custom domain via Route 53
  • CloudFront CDN
  • Monitoring with CloudWatch

Final Thoughts

Building this project deepens understanding of AWS networking, security, and scalability. If you’re learning AWS or preparing for cloud roles, implement it once—you’ll remember it forever.

Happy Clouding! ☁️🚀

Back to Blog

Related posts

Read more »

10 Proven Ways to Cut Your AWS Bill

Right‑size your EC2 instances One of the most common reasons for high AWS bills is over‑provisioned EC2 instances. Many systems use only a fraction of their ca...