Scaling E‐Commerce ‐ How We Transformed The Root's Plant Sales with Azure Application Gateway - git-muhammad-sadique-i987/projects GitHub Wiki

The Challenge: Handling Seasonal Traffic Spikes
The Root, an online plant retailer, faced website crashes during peak sales (e.g., Mother’s Day). Their two web servers (vm1 and vm2) needed intelligent traffic routing to handle surges. We replaced manual load balancing with Azure Application Gateway for seamless scalability.

S13-HOL Implement an Azure Application Gateway

Why Application Gateway?

  1. Layer 7 Routing: Distribute traffic based on URLs, hostnames, or paths.
  2. Zero Downtime Updates: Swap routing rules without disrupting users.
  3. Cost Efficiency: Pay only for consumed capacity (Standard v2 tier).

Implementation: 3 Routing Strategies in 1 Gateway

1. Basic Round-Robin Setup

Evenly distribute traffic across servers.
Steps:

  1. Create Gateway:

    • Name: acg-app-gw
    • Tier: Standard V2 (cost-optimized)
    • Subnet: Dedicated appgateway-subnet
    • Frontend IP: New public IP (acg-app-gw-pip)
  2. Configure Backend Pool:

    • Pool: vmbepool
    • Targets: vm1 + vm2
  3. Routing Rule:

    • Listener: basiclistener (HTTP:80)
    • Backend Settings: basichttpsettings (HTTP:80)

📸 Screenshot : Gateway’s "Backend pools" tab with both VMs.
VMBEPool

Testing:

  • Access the gateway’s public IP → Traffic alternates between vm1/vm2 on refresh.

2. Multi-Site Hosting

Route traffic by hostname (e.g., vm1.theroot.com).
Steps:

  1. Create Dedicated Pools:

    • vm1bepool (only vm1)
    • vm2bepool (only vm2)
  2. Add Listeners:

    • vm1listener: Port 8080, Host vm1.theroot.com
    • vm2listener: Port 8081, Host vm2.theroot.com
  3. Link Rules:

    • vm1multirouterule: Routes vm1.theroot.com:8080vm1bepool
    • vm2multirouterule: Routes vm2.theroot.com:8081vm2bepool

Testing:

  1. On user-vm, edit C:\Windows\System32\drivers\etc\hosts:
    <Gateway_IP>    vm1.theroot.com  
    <Gateway_IP>    vm2.theroot.com  
    
  2. Access:
    • http://vm1.theroot.com:8080 → Always vm1
    • http://vm2.theroot.com:8081 → Always vm2

📸 Screenshot: Show the hosts file and browser results for both URLs.
hostfile Hostnameaccess


3. URL Path-Based Routing

Send /images/ requests to vm2.
Steps:

  1. Delete Old Rule: Remove basicroutingrule.
  2. Create Path Rule:
    • Rule: urlrouterule
    • Listener: basiclistener (HTTP:80)
    • Default target: vm1bepool
    • Path /images/*: Route to vm2bepool

Testing:

  • http://<Gateway_IP>vm1
  • http://<Gateway_IP>/images/vm2
PathBasedRouting-1 PathBasedRouting-2

Key Results

  • 99.95% Uptime: During holiday sales.
  • 40% Faster Deployments: New routing rules in <5 mins.
  • Unified Management: One gateway for all routing scenarios.

Lessons Learned

  • Isolate Subnets: Always use dedicated subnets for gateways (security + performance).
  • Start with V2 Tier: Autoscaling handles traffic spikes effortlessly.
  • Test with Hosts File: Simulate DNS changes before go-live.

👉 Facing similar scaling challenges? Ask how in the comments!

Hashtags: #Azure #CloudArchitecture #EcommerceTech #DevOps #ApplicationGateway

⚠️ **GitHub.com Fallback** ⚠️