A hands-on load balancing lab in fifteen slides, in the console and the CLI: add the NAT gateway back and check the AMI, role and security group; create the ALB's security group, the target group project-web-tg and the ALB project-alb; create the launch template project-web-lt and the Auto Scaling group project-web-asg across two AZs, and see the requests spread; terminate a server and watch the group replace it; load the CPUs with stress-ng and watch the group scale out to four and back to two; then clean up.
The slides
The tool is a hands-on lab in fifteen slides, one step each, with the steps to follow beside a terminal and a picture
of the load balancer, the VPC's two AZs, the group's servers with their health and CPU, and the parts beside them:
- Introduction: what the lab makes.
- 1. What the lab needs
- Add the NAT gateway back:
project-nat in public-a, and the private route through it. - Check the AMI, the role and the security group:
project-web-ami, project-web-role, project-web-sg.
- 2. The load balancer
- Create the load balancer's security group:
project-alb-sg, and the web servers' rule pointing at it. - Create the target group:
project-web-tg, with a faster health check. - Create the Application Load Balancer:
project-alb, answering 503 with no targets.
- 3. The Auto Scaling group
- Create the launch template:
project-web-lt, with user data that writes the server's ID into its page. - Create the Auto Scaling group:
project-web-asg, 2 to 4 servers, target tracking at 50% CPU. - See the load balancer spread the requests: two servers answering in turn.
- 4. Recovery
- Terminate a server: the target drains, and a replacement launches.
- Watch the group recover: the cause, and the new server healthy.
- 5. Scaling
- Load the servers' CPUs: stress-ng on every server, with Run Command.
- Watch the group scale out: the alarm, and the desired capacity from 2 to 4.
- Watch the group scale in: back to 2 when the load stops.
- 6. Clean up: the group, the load balancer, the target group, the template, the security group and the NAT gateway.
The buttons on the left and right edges move between slides. So do the arrow keys and a swipe.
The lab uses the VPC of session 4's lab, the role of session 3's second lab and the AMI of session 5's lab, and says
how to rebuild them. The slides
Load Balancing and Auto Scaling explain
what it uses.
The placeholders
The instance IDs, the load balancer's DNS name and the security group IDs are placeholders in AWS's form
(i-1234567890abcdef0). The lab has not yet been run in a real account: the outputs follow the CLI's service model,
and the scaling activities' causes their documented form.
Sources