<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Habibullah Jubair on Medium]]></title>
        <description><![CDATA[Stories by Habibullah Jubair on Medium]]></description>
        <link>https://medium.com/@hmjubair12?source=rss-c8c303ad3251------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*psg6NWsNOftpUInD</url>
            <title>Stories by Habibullah Jubair on Medium</title>
            <link>https://medium.com/@hmjubair12?source=rss-c8c303ad3251------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 19:32:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hmjubair12/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Highly Available Web Architecture on AWS: ALB + Auto Scaling Group Across 2 Availability…]]></title>
            <link>https://medium.com/@hmjubair12/building-a-highly-available-web-architecture-on-aws-alb-auto-scaling-group-across-2-availability-bb119d0e2c13?source=rss-c8c303ad3251------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb119d0e2c13</guid>
            <dc:creator><![CDATA[Habibullah Jubair]]></dc:creator>
            <pubDate>Mon, 13 Apr 2026 11:27:09 GMT</pubDate>
            <atom:updated>2026-04-13T11:27:09.980Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Highly Available Web Architecture on AWS: ALB + Auto Scaling Group Across 2 Availability Zones</h3><p>A practical walkthrough on deploying fault-tolerant, auto-scaling infrastructure using AWS native services</p><h3>Why High Availability Matters</h3><p>Imagine your application goes down because a single server crashes — or worse, an entire data center in one region experiences an outage. For any production-grade system, this is unacceptable.</p><p>High availability (HA) is the practice of designing systems that remain operational even in the face of failures. AWS makes this achievable with a combination of <strong>Application Load Balancers (ALB)</strong>, <strong>Auto Scaling Groups (ASG)</strong>, and <strong>multi-AZ deployments</strong> — all without managing a single server cluster manually.</p><p>In this blog, I’ll walk you through how I built a highly available web architecture on AWS that:</p><ul><li>Distributes traffic across <strong>two Availability Zones</strong> (us-east-1a and us-east-1b)</li><li>Automatically <strong>recovers from instance failures</strong></li><li><strong>Scales out</strong> under heavy load and <strong>scales in</strong> when traffic drops</li><li>Uses a real <strong>user data script</strong> to bootstrap EC2 instances automatically</li></ul><h3>Architecture Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PR5h9oCk8UVHMB_TT1aDow.png" /></figure><p>The ALB distributes incoming HTTP traffic across healthy EC2 instances in the Target Group. The ASG ensures the desired number of instances are always running — replacing unhealthy ones and launching new ones when traffic spikes.</p><h3><strong>What We’ll Build</strong></h3><p>VPC + Public Subnets (2 AZs)</p><p>2. Security Groups</p><p>3. Launch Template</p><p>4. Target Group</p><p>5. Application Load Balancer</p><p>6. Auto Scaling Group</p><h3>Step 1 — Create a VPC with Subnets in 2 Availability Zones</h3><p>Start by creating a <strong>VPC</strong> and two <strong>public subnets</strong>, each in a different Availability Zone — us-east-1a and us-east-1b.</p><p>Using the AWS VPC creation wizard, you can generate all subnets in one step. Make sure:</p><ul><li>Each subnet is in a <strong>different AZ</strong></li><li>Public subnets have <strong>Auto-assign public IP</strong> enabled</li><li>An <strong>Internet Gateway</strong> is attached and route tables point 0.0.0.0/0 to it</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y09n0iyMub5TaSGaKNZzWQ.png" /></figure><p><em>Spreading subnets across 2 AZs is the foundation of fault tolerance. If one AZ goes down, your app keeps running in the other one.</em></p><h3>Step 2 — Security Groups</h3><p>We need two security groups with a strict trust chain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yjvAO1MNPRs34o5eH_MpZw.png" /></figure><p><strong>ALB Security Group</strong></p><p>Inbound — — HTTP — — 80 — — 0.0.0.0/0 (the internet)</p><p><strong>EC2 / ASG Security Group</strong></p><p>Inbound — — HTTP — — 80 — — <strong>ALB Security Group</strong> (not 0.0.0.0/0)</p><blockquote>This is a critical security principle: your EC2 instances <strong>never accept direct traffic from the internet</strong>. They only receive traffic forwarded by the ALB.</blockquote><h3>Step 3 — Launch Template</h3><p>The Launch Template defines everything the ASG needs to spin up a new instance:</p><ul><li><strong>AMI</strong>: Ubuntu Server</li><li><strong>Instance type</strong>: t2.micro</li><li><strong>Security group</strong>: The EC2/ASG security group from Step 2</li><li><strong>User data script</strong>: The bootstrap script that installs Apache automatically</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2NxPhWqXvRwEcxWpsCMbig.png" /></figure><p>The User Data Script</p><pre>#!/bin/bash<br>apt update -y<br>apt install -y apache2<br>systemctl start apache2<br>systemctl enable apache2<br>echo &quot;&lt;h1&gt;ALB + Auto Scaling Web Server&lt;/h1&gt;&lt;h2&gt;Hostname: $(hostname)&lt;/h2&gt;&quot; &gt; /var/www/html/index.html</pre><blockquote>This script runs <strong>automatically</strong> when each new instance launches. Within a minute, a fresh EC2 instance will have Apache installed and serving a page that displays its own hostname — which is a great way to verify that the ALB is routing traffic to different instances.</blockquote><h3>Step 4 — Create a Target Group</h3><p>The Target Group is the bridge between the ALB and your EC2 instances.</p><p><strong>Configuration:</strong></p><ul><li><strong>Target type</strong>: Instances</li><li><strong>Protocol</strong>: HTTP, Port 80</li><li><strong>Health check path</strong>: /</li><li><strong>Healthy threshold</strong>: 2 consecutive successes</li><li><strong>Unhealthy threshold</strong>: 3 consecutive failures</li><li><strong>Health check interval</strong>: 100 seconds</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vl1dcFG1OK1GWykJ1LuQUQ.png" /></figure><p>Health checks are what make high availability actually work. The ALB regularly pings each instance. If an instance stops responding, the ALB stops routing traffic to it — automatically.</p><blockquote>You don’t register instances manually here. The ASG will do that automatically when it launches instances.</blockquote><h3>Step 5 — Create the Application Load Balancer</h3><p>Now create the ALB and tie everything together.</p><p><strong>Configuration:</strong></p><ul><li><strong>Scheme</strong>: Internet-facing</li><li><strong>IP address type</strong>: IPv4</li><li><strong>VPC</strong>: Your VPC from Step 1</li><li><strong>Subnets</strong>: Select <strong>both</strong> public subnets (us-east-1a and us-east-1b)</li><li><strong>Security group</strong>: The ALB security group from Step 2</li><li><strong>Listener</strong>: HTTP on port 80, forwarding to your Target Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*331AzgwuITQZCRkBCHHihg.png" /></figure><p>The ALB is now live, but there are no instances behind it yet — the ASG will handle that.</p><h3>Step 6 — Create the Auto Scaling Group</h3><p>This is where everything comes together.</p><p><strong>Configuration:</strong></p><ul><li><strong>Launch template</strong>: The one you created in Step 3</li><li><strong>VPC and Subnets</strong>: Select <strong>both</strong> subnets (us-east-1a and us-east-1b)</li><li><strong>Load balancing</strong>: Attach to your existing Target Group</li><li><strong>Health check type</strong>: ELB (so the ALB’s health checks drive ASG decisions)</li><li><strong>Desired capacity</strong>: 2</li><li><strong>Minimum capacity</strong>: 1</li><li><strong>Maximum capacity</strong>: 4</li></ul><h3>Dynamic Scaling — Target Tracking Policy</h3><p>For scaling, I used a <strong>Dynamic Scaling Policy</strong> with <strong>Target Tracking</strong> based on CPU utilization:</p><ul><li><strong>Policy type</strong>: Target tracking scaling</li><li><strong>Metric</strong>: Average CPU Utilization</li><li><strong>Target value</strong>: <strong>50%</strong></li></ul><blockquote>This tells the ASG: <em>“Keep average CPU across all instances around 50%. If it goes above, launch more instances. If it drops well below, terminate some.</em></blockquote><h3>Verifying It Works</h3><p>Once the ASG launches instances and they pass health checks, grab the <strong>ALB DNS name</strong> from the AWS console. Open it in your browser. You should see a page served from one of your instances:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PxNeJL9-yqatXpWdExHZSA.png" /></figure><p>Refresh the page a few times. The hostname <strong>changes</strong> — the ALB is round-robining between your instances across the two AZs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U6HLX08WW4SB1KBVCSr0SA.png" /></figure><p>Each response comes from a different EC2 instance — proof that load balancing across AZs is working correctly.</p><h3>Testing High Availability</h3><h3><strong>Test 1 — Instance Failure</strong></h3><ol><li>Go to EC2 console and <strong>manually stop</strong> one of your instances</li><li>The Target Group health checks mark it as unhealthy within ~30 seconds</li><li>The ALB stops routing traffic to it automatically</li><li>The ASG detects the instance count is below desired and <strong>launches a replacement</strong></li></ol><p>Traffic continues to flow to the healthy instance throughout. Zero downtime.</p><h3>Test 2 — Load-Based Scale Out</h3><ol><li>Use a load testing tool like ab (Apache Bench) to hammer your ALB endpoint or use stress tools into ec2 instance</li><li>Watch CPU spike across your instances in CloudWatch</li><li>Once CPU crosses 50%, the Target Tracking policy triggers and the ASG <strong>launches new instances</strong></li><li>When load drops, CPU falls and the ASG <strong>terminates the extra instances</strong> automatically</li></ol><h3>Conclusion</h3><p>With just six steps, you’ve built an infrastructure that survives AZ-level failures, heals itself automatically, and scales with demand based on real CPU metrics.</p><p>This pattern — ALB + ASG + multi-AZ with Target Tracking — is the bread and butter of production AWS deployments. It’s the foundation that thousands of companies rely on, and now you know how to build it yourself.</p><p><strong>GitHub Repository</strong>: <a href="https://github.com/jubair2002/highly-Available-Architecture-ALB-ASG-AWS">highly-Available-Architecture-ALB-ASG-AWS</a></p><p>Tags : #aws #highAvailability #devops #autoscaling #infrastructure #alb #loadbalancers</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb119d0e2c13" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>