**📌 Why Use an ALB?
An ALB allows you to:
Route incoming HTTP/HTTPS requests to multiple targets (like EC2 instances)
Perform content-based routing (e.g., by path or hostname)
Automatically distribute traffic for better availability and fault tolerance
🛠️ Setup Overview
I’ve set up two EC2 instances and registered them as targets in an ALB. Here's a peek into the second instance where I’m serving an HTML page:
🖥️ EC2 Instance 2 HTML
html
Copy
Edit
this is 2nd machine
This response helps verify which instance the ALB routes to.
⚙️ Instance Info:
Instance ID: i-0629d026affe9d681
Public IP: 54.254.195.152
Private IP: 172.31.20.176
🔁 Load Balancer Setup (Steps)
Create an ALB from the AWS console.
Choose Application Load Balancer.
Select VPC and availability zones.
Add a listener on port 80 (HTTP).
Create a target group and register both EC2 instances.
Deploy a simple web server (like NGINX or a static HTML file) on each instance.
Test the DNS of the ALB in the browser.
💡 Pro Tip: Use a different message or HTML on each instance so you know which one handled the request.
✅ Final Test
Once it’s all set up, open the ALB DNS URL in your browser and refresh. You should see different responses (like "this is 2nd machine") depending on which EC2 instance served the request.**