Thursday, December 19, 2024

Configure ALB with Auto Scaling

In This Blog We are going to Configure AWS Application load Balancer with Auto Scaling Group with Demo Project.


Step 1: Launch an EC2 Instance and Prepare AMI

👉 Launch EC2 Instance.

  • Install Demo Script:


Step 2: Set Up Application Load Balancer (ALB)

👉 Create Application Load Balancer.
  • Name: My-ALB
  • Scheme: Internet-facing (for public access).
  • Availability Zones: Choose at least two AZs for redundancy.
  • Security Group
  • Listeners: HTTP (Port 80) Or HTTPS (Port 443).     

👉 Create Target Group:
  • Target Type: Instance.
  • Name: My-TG
  • Health Check: HTTP, `/` endpoint.
  • Register your EC2 instances   

👉 Back To Our Previous Tab:
  • Select Target Group
  • Click On create load balancer


Step 3: Create EC2 AMI and Launch Template For Auto Scaling Group.


👉 Create EC2 AMI

 
👉 Create Launch Template

  • Name:My-LT
  • Selected Created AMI
  • Instance Type : t2.medium
  • Key Pair : Selected Existing
  • Security Group : Selected Existing


Step 4: Set Up Auto Scaling Group (ASG)     

👉 Create Auto Scaling Group:

  • Name :My-ASG
  • Select the previously created Launch Template.
  • Leave As Default and Next

👉 Load Balancing:Attach to an existing load balancer
  • Select the previously created Target Group.
  • Leave As Default and Next

👉 Configure Group Size:
  • Set Desired Capacity (e.g., 2 instances).
  • Set Minimum Capacity (e.g., 2 instances).
  • Set Maximum Capacity (e.g., 5 instances).

👉 Configure Target Scaling Policies:
  • Scale based on CPU utilization (e.g., > 60%).

👉 Add Notifications (Optional):

     
Step 5: Test Load Balancer and Auto Scaling.


👉 Manually Stop the Current Running Instances.
  • Verify The New Instances Being Created or Not ?


👉 Execute The Stress cmd to put testing load on CPU.

  • stress --cpu 4 --timeout 600


👉 Verify The New Instances Being Created or Not ?



Step 6: Add SNS Notifications (Optional):


Step 7: Enable HTTPS (Optional)


Step 8: Monitoring and Logs (Optional)
      


 Now Few Questions Should in Your Mind 🤔 ?

  • How to point a domain name to an Application Load Balancer ?
  • How to point a domain name to an ALB and enable HTTPS?
  • How to configure a Python project with auto-scaling?
  • How to configure a React project with auto-scaling?
  • How to configure a WordPress project with auto-scaling?
  • How to configure mysql database in auto-scaling scenario ?
  • What is the Cost Structure of Load Balancer and Auto Scaling?

 

No comments:

Post a Comment

testing