Implementing EC2 Auto Scaling Using CloudWatch Metrics (Hands-On Lab)

📌 Objective
In this hands-on lab, I practiced Amazon EC2 Auto Scaling by configuring a scaling policy based on CloudWatch CPU utilization metrics.
The goal was to automatically scale out EC2 instances when average CPU utilization crosses 50%, and verify the behavior by generating load on the instance.
🧱 Prerequisites
Before starting, the following were required:
An active AWS account
Basic understanding of:
EC2
CloudWatch
Auto Scaling concepts
Access to the EC2 dashboard
SSH access to EC2 instances
🧱 Services Used (Brief Overview)
🔹 Amazon EC2
Used to launch compute instances and define launch configurations for the Auto Scaling Group.
🔹 Amazon CloudWatch
Monitored CPU utilization metrics and triggered scaling actions based on defined thresholds.
🔹 Amazon EC2 Auto Scaling
Automatically added or removed EC2 instances based on CloudWatch metrics.
🧠 Auto Scaling Basics
Before implementation, I reviewed the core concepts:
🔸 Vertical Scaling
- Increasing the capacity (CPU/RAM) of a single instance
🔸 Horizontal Scaling
- Adding or removing multiple instances
🔸 Auto Scaling
Part of horizontal scaling
Scales EC2 instances automatically based on CloudWatch metrics
Supports:
Scale-out (add instances)
Scale-in (remove instances)
🧪 Step-by-Step Lab Execution
Step 1️⃣ Create Launch Configuration
Navigate to EC2 Dashboard
Go to Launch Configurations
Click Create launch configuration
Select:
Amazon Machine Image (AMI)
Instance type
Enable Detailed Monitoring (important for faster scaling response)
Configure remaining settings
Create the launch configuration



Step 2️⃣ Create Auto Scaling Group
Navigate to Auto Scaling Groups
Click Create Auto Scaling Group
Select the previously created Launch Configuration
Choose:
VPC
Subnet
Set desired, minimum, and maximum instance capacity




Step 3️⃣ Configure Scaling Policy
Choose Target Tracking Scaling Policy
Select metric:
- Average CPU Utilization
Set target value:
- 50%
(Optional) Configure notifications
Create the Auto Scaling Group


Step 4️⃣ Verify Auto Scaling Group Creation
Confirm Auto Scaling Group status
Ensure initial EC2 instance is running
Verify instance is launched via the Auto Scaling Group

Step 5️⃣ Generate CPU Load for Testing
To test scaling behavior, I increased CPU utilization beyond 50%.
Connect to the EC2 instance using SSH
Install the stress utility
Run the stress command to increase CPU usage

Step 6️⃣ Monitor CPU Utilization in CloudWatch
Navigate to CloudWatch → Metrics
Open EC2 → Per-Instance Metrics
Observe CPU utilization crossing 50%

Step 7️⃣ Observe Auto Scaling Action
Once CPU utilization exceeded the threshold:
Auto Scaling policy was triggered
New EC2 instances were launched automatically
Instance count increased without manual intervention

✅ Final Outcome
Auto Scaling Group successfully scaled out
Scaling was triggered purely by CloudWatch CPU metrics
The setup demonstrated real-time, automated infrastructure scaling
🧠 Key Learnings
Auto Scaling is a core part of high availability and performance
CloudWatch metrics directly drive scaling decisions
Target tracking policies simplify scaling configuration
Stress testing is an effective way to validate scaling behavior
Detailed monitoring improves scaling responsiveness
📎 Conclusion
This hands-on lab helped me understand how Amazon EC2 Auto Scaling works in real-world scenarios.
By combining CloudWatch metrics with target tracking scaling policies, infrastructure can automatically adapt to workload changes, improving both reliability and efficiency.
I’ll continue practicing similar AWS labs to strengthen my cloud fundamentals through real implementations.

