AWS Certified Cloud Practitioner / ELB & ASG - Elastic Load Balancing & Auto Scaling Groups

Auto-Scaling Groups (ASG Overview)

1️⃣ Why Auto Scaling?

Real traffic is never constant πŸ“Š

  • 🌞 Day β†’ high traffic

  • πŸŒ™ Night β†’ low traffic

If you size your servers for one fixed number, you always lose:

  • Size for peak traffic β†’ you overpay πŸ’Έ during quiet hours, running servers nobody needs

  • Size for average traffic β†’ you crash ❌ the moment traffic spikes above it

πŸ’‘ The fix: an Auto Scaling Group (ASG) watches real demand and adjusts the number of EC2 instances for you β€” automatically, in both directions.


2️⃣ What an ASG Actually Does

An ASG constantly compares current load against your configured thresholds and reacts:

βž• Scale out β€” add instances

When traffic climbs πŸ“ˆ, the ASG launches more EC2 instances πŸ’»πŸ’»πŸ’» to absorb the load.

βž– Scale in β€” remove instances

When traffic drops πŸ“‰, the ASG terminates instances it no longer needs, so you stop paying for idle capacity.

🎯 The goal isn't "more" or "fewer" servers β€” it's always running the right number for current demand.


3️⃣ Architecture: ALB + ASG Together

Users 🌍 β†’ βš–οΈ Load Balancer β†’ βš™οΈ Auto Scaling Group β†’ πŸ’» EC2 Instances

The load balancer is the fixed entry point traffic hits first. Behind it, the ASG owns the instances β€” deciding how many exist at any moment and handing that live pool to the load balancer to distribute traffic across.

!image.png


4️⃣ Key ASG Settings

Every ASG is defined by three numbers that set its scaling boundaries:

πŸ”’ Minimum capacity

The floor β€” the ASG will never run fewer than this many instances, even at zero traffic. πŸ‘‰ Example: 1

🎯 Desired capacity

The target it maintains under normal conditions β€” what "steady state" looks like for your app. πŸ‘‰ Example: 2

πŸš€ Maximum capacity

The ceiling β€” the most instances the ASG is allowed to launch, no matter how high traffic spikes. This caps your worst-case cost. πŸ‘‰ Example: 5

Put together:

Min = 1
Desired = 2
Max = 5

πŸ‘‰ Day to day, the ASG sits at 2 instances. Under load, it can scale anywhere between 1 and 5 β€” but never outside that range.


5️⃣ ASG + Load Balancer: The Key Integration

Scaling only helps if new traffic actually finds the new instances β€” and that's handled automatically:

  • Instance created βž• β†’ it's automatically registered with the ALB's target group and starts receiving traffic

  • Instance removed βž– β†’ it's automatically deregistered, so the ALB stops sending it traffic before it disappears

πŸ‘‰ You never manually add or remove targets β€” the ASG and ALB stay in sync on their own πŸ€–


6️⃣ Self-Healing: Free Fault Tolerance

Auto scaling isn't just about load β€” it also protects against failure.

πŸ’₯ If an instance fails:

  1. The ASG detects it's unhealthy ❌ (via the same health checks the ALB uses)

  2. It terminates the failed instance 🧹

  3. It immediately launches a fresh replacement βœ… to keep the group at its desired capacity

🎯 Result: your app recovers from a crashed server without you touching anything.


7️⃣ Cost Optimization

  • Without ASG: you provision for peak traffic and pay for that capacity 24/7 πŸ’Έ, even while most of it sits idle

  • With ASG: capacity tracks demand in real time β€” you pay for roughly what you actually use 🎯

πŸ‘‰ This is what "elastic" in elastic cloud computing really means.


βš–οΈ ASG vs Load Balancer β€” Different Jobs

They're often used together, but they solve different problems:

  • Role: the Load Balancer distributes traffic; the ASG manages how many instances exist

  • Handles failures: both do β€” the ALB routes around an unhealthy instance, the ASG replaces it

  • Scaling: only the ASG scales capacity up or down

  • Entry point: only the ALB is a traffic entry point; the ASG has no public address


πŸ“ Exam Tips (very important)

  • ASG = elasticity ⚑

  • Scale out = add instances βž•

  • Scale in = remove instances βž–

  • Works together with an ALB βš–οΈ

  • Self-healing = automatically replaces unhealthy instances πŸ›‘οΈ