Skip to content

cnwanze-cloud/highly-available-web-app-infrastructure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PayFlow AWS Highly Available Web Infrastructure

Project Overview

This project demonstrates the design and deployment of a highly available, scalable, and secure web application infrastructure on Amazon Web Services (AWS).


Project Architecture

Architectural Diagram 1 --- Architectural Diagram 2

Architecture Summary

  • Custom VPC with public and private subnets across multiple Availability Zones
  • Internet Gateway for public access
  • NAT Gateway for private subnet outbound internet access
  • Application Load Balancer for traffic distribution
  • Auto Scaling Group for elasticity
  • EC2 instances running a simple Apache web application

Tech Stack

  • Amazon VPC
  • EC2 (Amazon Linux)
  • Application Load Balancer (ALB)
  • Auto Scaling Groups
  • NAT Gateway / Internet Gateway
  • IAM & Security Groups
  • Apache Web Server (User Data bootstrapping)

Skills Demonstrated

  • AWS Cloud Architecture Design
  • Networking (VPC, Subnets, Routing)
  • Load Balancing & Auto Scaling
  • Cloud Security (IAM, Security Groups)
  • Linux Server Configuration
  • High Availability System Design
  • Production-grade infrastructure thinking

Step-by-Step Implementation


1. Create VPC

  • Navigate to VPC → Create VPC
  • Configuration:
    • Name: payflow-vpc
    • IPv4 CIDR: 10.0.0.0/16
image

2. Create Subnets

Public Subnets (Load Balancer Layer)

Subnet 1

  • Name: public-subnet-1
  • CIDR: 10.0.1.0/24
  • AZ: us-east-1a

Subnet 2

  • Name: public-subnet-2
  • CIDR: 10.0.2.0/24
  • AZ: us-east-1b

Private Subnets (EC2 Instances)

Subnet 3

  • Name: private-subnet-1
  • CIDR: 10.0.3.0/24
  • AZ: us-east-1a

Subnet 4

  • Name: private-subnet-2
  • CIDR: 10.0.4.0/24
  • AZ: us-east-1b
image

3. Create Internet Gateway

  • Name: payflow-igw
  • Attach it to payflow-vpc
image

4. Create Route Tables

Public Route Table

  • Name: public-rt
  • Route:
    • Destination: 0.0.0.0/0
    • Target: Internet Gateway
  • Associate with:
    • public-subnet-1
    • public-subnet-2
image

Private Route Table

  • Name: private-rt
  • Associate with:
    • private-subnet-1
    • private-subnet-2
image

5. Create NAT Gateway

  • Place NAT Gateway in: public-subnet-1
  • Allocate an Elastic IP
image

Update Private Route Table

  • Add route:
    • Destination: 0.0.0.0/0
    • Target: NAT Gateway
image

6. Security Groups

ALB Security Group

  • Allow:
    • HTTP (Port 80) from 0.0.0.0/0

EC2 Security Group

  • Allow:
    • HTTP (Port 80) ONLY from ALB Security Group
image

7. Create Web Application (EC2 Instance)

  • Launch EC2 instance in private subnet
  • Amazon Linux AMI
  • Install Apache web server using User Data:
#!/bin/bash
yum update -y
yum install -y httpd

systemctl enable httpd
systemctl start httpd

echo "PayFlow Server - $(hostname)" > /var/www/html/index.html
image

8. Create AMI (Golden Image)

  • Convert the configured EC2 instance into an Amazon Machine Image (AMI)
  • This AMI captures:
  • OS configuration
  • Installed packages (Apache HTTP Server)
  • Application setup
  • The AMI will be used by the Auto Scaling Group to launch identical instances
image

9. Create Launch Template

The Launch Template defines how new EC2 instances will be created.

Configuration:

  • AMI: Custom Amazon Linux AMI
  • Instance Type: t3.micro
  • Key Pair: Configured SSH key pair
  • Security Group:
  • Allow HTTP (Port 80)
  • User Data Script:
  • Installs and configures Apache HTTP Server
image

10. Create Target Group

The Target Group is used by the Load Balancer to route traffic.

Configuration:

  • Type: Instances
  • Protocol: HTTP
  • Port: 80

Health Check

  • Path: /
  • Ensures only healthy instances receive traffic
  • Unhealthy instances are automatically removed from routing
image

11. Create Application Load Balancer (ALB)

  • Type: Internet-facing Load Balancer
  • Listener: HTTP (Port 80)

Subnets:

  • public-subnet-1
  • public-subnet-2

Attachments:

  • Connect ALB to the Target Group
image

12. Create Auto Scaling Group (ASG)

The ASG ensures high availability and elasticity.

Configuration:

  • Launch Template: Previously created template
  • Subnets:
  • private-subnet-1
  • private-subnet-2
  • Attach Target Group

Scaling Settings:

  • Minimum Instances: 2
  • Desired Instances: 2
  • Maximum Instances: 4
image

13. Configure Auto Scaling Policies Using Dynamic Policy (Step Scaling)

Scale Out Policy

  • If CPU utilization > 70%
  • ➜ Add more EC2 instances automatically

Scale In Policy

  • If CPU utilization < 30%
  • ➜ Remove excess EC2 instances
image image

14. Testing Load Balancing

To verify the setup:

  1. Copy the ALB DNS name
  2. Paste it into a browser
  3. Refresh multiple times

Expected Result:

  • Different EC2 hostnames appear on each refresh
  • Traffic is distributed across multiple instances
  • Load Balancing is working correctly
image image

Outcome

A fully scalable, fault-tolerant web application infrastructure capable of automatically handling traffic changes while maintaining high availability.

Security Highlights

• EC2 instances deployed in private subnets • No direct public access to backend servers • Controlled traffic via ALB only • Security groups enforcing least privilege access

About

Scalable AWS web app using EC2, ALB, and Auto Scaling Groups.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages