DEV Community

Cover image for Smart Routing & Auto Scaling with ALB and ASG in AWS - Part 2
AKASH S
AKASH S

Posted on

Smart Routing & Auto Scaling with ALB and ASG in AWS - Part 2

Introduction to Application Load Balancer (ALB)

As we went deeper into AWS, we discovered the Application Load Balancer (ALB) a more advanced and flexible version of CLB.

Unlike CLB, which sends traffic blindly, ALB is context-aware. It looks at the request’s path or hostname and decides which server should handle it.

How We Used ALB: Step-by-Step

1) Launched EC2 Instances

  • ne for /app1
  • One for /app2
  • Each had its own custom index.html

2)Created Target Groups

  • Each group pointed to different EC2s
  • Configured health checks on /index.html

3)Created an ALB

  • Selected Internet-facing
  • Chose appropriate VPC and Availability Zones
  • Enabled HTTP listener on port 80
  • Assigned a security group with HTTP and SSH

4)Added Path-Based Routing Rules

  • /app1 → Target Group A
  • /app2 → Target Group B
  • We can also configure host-based routing (e.g., admin.ourapp.com)

Real-World Example: Online Food Ordering App

we’re building a Zomato or Swiggy-like app:

  • /menu → Served from one backend
  • /checkout → Comes from another backend
  • /admin → Managed through a different instance

Here, ALB works like a digital receptionist:

  • It understands our user’s request.
  • Then routes it to the correct backend based on the URL.

What About Auto Scaling Group (ASG)?

Once we configured ALB for smart routing, we integrated Auto Scaling Group (ASG) to handle traffic spikes automatically.

With ASG:

As traffic increases → New EC2s are launched automatically

As traffic drops → Unneeded EC2s are terminated

Real-World Example: IPL Live Score App

Imagine we're running a site that shows live cricket scores:

  • During the match, millions of fans visit the site → ASG launches extra instances
  • After the match, traffic reduces → ASG removes the extra machines

Meanwhile, ALB keeps routing traffic only to the healthy instances.

Summary:

  • ALB gives us smart routing based on URL paths or domains.
  • Target Groups help organize and manage our backend services.
  • ASG makes our application elastic, scaling with demand.

This was a game-changing learning experience — and we’re just getting started.
More AWS experiments coming soon!

Top comments (0)