By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
For AWS Solutions Architect – Associate (SAA-C03) & Real-World Deployments
You’re a cloud engineer at a fintech startup. Your app runs on EC2 instances, but traffic spikes during market hours crash your servers. Worse, your monolithic backend can’t scale horizontally. Elastic Load Balancing (ELB) is your superpower: it distributes traffic across multiple targets (EC2, Lambda, containers), improves fault tolerance, and enables zero-downtime deployments.
Why this matters in production:- Without ELB: A single EC2 instance fails → your app goes down. Users see 503 errors.- With ELB: Traffic auto-routes to healthy instances. You can roll out updates without downtime.- Security: ALBs terminate TLS, reducing load on your servers. NLBs preserve client IPs for logging.- Cost: You pay only for what you use ($0.0225/hour for ALB + $0.008/GB data processed).
Real-world scenario:You inherit a legacy app with a single EC2 instance. Your CTO demands 99.99% uptime. You’ll use an ALB to: 1. Distribute traffic across 3 AZs.2. Terminate HTTPS at the load balancer (offloading SSL from EC2).3. Route /api to a new Lambda function and /static to S3.
/api
/static
ProcessedBytes
/users
/orders
Prerequisites:- AWS account with admin IAM permissions.- 2+ EC2 instances (Amazon Linux 2) in different AZs (e.g., us-east-1a, us-east-1b).- A registered domain (e.g., example.com) in Route 53 (optional but recommended).
us-east-1a
us-east-1b
example.com
# Launch 2 EC2 instances in different AZs aws ec2 run-instances \ --image-id ami-0c55b159cbfafe1f0 \ # Amazon Linux 2 --instance-type t3.micro \ --key-name MyKeyPair \ --security-group-ids sg-12345678 \ # Allow HTTP (80) from ALB --subnet-id subnet-12345678 \ # us-east-1a --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=WebServer1}]' aws ec2 run-instances \ --image-id ami-0c55b159cbfafe1f0 \ --instance-type t3.micro \ --key-name MyKeyPair \ --security-group-ids sg-12345678 \ --subnet-id subnet-87654321 \ # us-east-1b --tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=WebServer2}]'
Verify:- SSH into each instance and install a web server: bash sudo yum update -y sudo yum install -y httpd sudo systemctl start httpd echo "<h1>Hello from $(hostname)</h1>" | sudo tee /var/www/html/index.html
bash sudo yum update -y sudo yum install -y httpd sudo systemctl start httpd echo "<h1>Hello from $(hostname)</h1>" | sudo tee /var/www/html/index.html
aws elbv2 create-target-group \ --name MyWebApp-TG \ --protocol HTTP \ --port 80 \ --vpc-id vpc-12345678 \ --health-check-path / \ --health-check-interval-seconds 30 \ --health-check-timeout-seconds 5 \ --healthy-threshold-count 2 \ --unhealthy-threshold-count 2 \ --target-type instance
Register targets:
aws elbv2 register-targets \ --target-group-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/MyWebApp-TG/1234567890abcdef \ --targets Id=i-1234567890abcdef0,Port=80 Id=i-0987654321fedcba0,Port=80
Verify health checks:
aws elbv2 describe-target-health \ --target-group-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/MyWebApp-TG/1234567890abcdef
Expected output:
{ "TargetHealthDescriptions": [ { "Target": { "Id": "i-1234567890abcdef0", "Port": 80 }, "HealthCheckPort": "80", "TargetHealth": { "State": "healthy" } } ] }
aws elbv2 create-load-balancer \ --name MyWebApp-ALB \ --subnets subnet-12345678 subnet-87654321 \ # Must be in 2+ AZs --security-groups sg-12345678 \ # Allow HTTP/HTTPS --scheme internet-facing \ --type application
Note the ALB ARN (e.g., arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/MyWebApp-ALB/1234567890abcdef).
arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/MyWebApp-ALB/1234567890abcdef
# Create an HTTP listener (port 80) aws elbv2 create-listener \ --load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/MyWebApp-ALB/1234567890abcdef \ --protocol HTTP \ --port 80 \ --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/MyWebApp-TG/1234567890abcdef
Optional: Add HTTPS (port 443) with ACM certificate:
aws elbv2 create-listener \ --load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:loadbalancer/app/MyWebApp-ALB/1234567890abcdef \ --protocol HTTPS \ --port 443 \ --certificates CertificateArn=arn:aws:acm:us-east-1:123456789012:certificate/12345678-1234-1234-1234-123456789012 \ --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/MyWebApp-TG/1234567890abcdef
bash aws elbv2 describe-load-balancers \ --names MyWebApp-ALB \ --query 'LoadBalancers[0].DNSName' \ --output text
bash curl http://MyWebApp-ALB-1234567890.us-east-1.elb.amazonaws.com
``` 3. Refresh multiple times—you should see responses from both EC2 instances.
bash aws route53 change-resource-record-sets \ --hosted-zone-id Z1234567890ABCDEFGHIJ \ --change-batch '{ "Changes": [{ "Action": "CREATE", "ResourceRecordSet": { "Name": "app.example.com", "Type": "A", "AliasTarget": { "HostedZoneId": "Z35SXDOTRQ7X7K", # ALB hosted zone ID (us-east-1) "DNSName": "dualstack.MyWebApp-ALB-1234567890.us-east-1.elb.amazonaws.com", "EvaluateTargetHealth": true } } }] }'
bash curl https://app.example.com
0.0.0.0/0
internal
/health
/
healthy-threshold=2
unhealthy-threshold=2
Environment=prod
Team=backend
HTTPCode_Target_5XX_Count
UnHealthyHostCount
RequestCount
HTTPCode_ELB_5XX_Count > 0
deregistration_delay.timeout_seconds=300
"You need ultra-low latency for a trading app. Which LB?" → NLB (~100ms latency).
TLS Termination:
"Where should you terminate TLS for a web app?" → ALB (offloads SSL from EC2).
Sticky Sessions:
"A user’s shopping cart disappears after refresh. What’s missing?" → Sticky sessions (ALB with app-cookie or lb-cookie).
app-cookie
lb-cookie
GWLB:
Challenge:Deploy an ALB that routes: - /api → Lambda function (returns {"status": "ok"}).- /static → S3 bucket (serves index.html).
{"status": "ok"}
index.html
Solution:1. Create a Lambda function: python def lambda_handler(event, context): return {"statusCode": 200, "body": '{"status": "ok"}'} 2. Create an S3 bucket and upload index.html.3. Create 2 target groups: - Lambda-TG (target type: Lambda). - S3-TG (target type: IP, point to S3 bucket’s VPC endpoint).4. Configure ALB listeners with path-based routing: - /api → Lambda-TG. - /static → S3-TG.
python def lambda_handler(event, context): return {"statusCode": 200, "body": '{"status": "ok"}'}
Lambda-TG
S3-TG
Why it works:ALB supports Lambda as a target and can route to S3 via VPC endpoints.
aws elbv2 create-load-balancer
aws elbv2 create-target-group
aws elbv2 register-targets
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.