One server is a single point of failure, and traffic is rarely steady. On AWS, the standard answer is an Application Load Balancer (ALB) in front of an Auto Scaling group of EC2 instances. Together they keep an app available and match capacity to demand.
Application Load Balancer
- Receives all incoming traffic on one address.
- Spreads requests across healthy instances in several Availability Zones.
- Runs health checks, such as requesting
/healthevery 30 seconds, and stops sending traffic to instances that fail. - Handles HTTPS with certificates from AWS Certificate Manager.
- Can route by path, for example
/apito one group of servers and everything else to another.
Auto Scaling group
An Auto Scaling group keeps a number of instances running between a minimum and a maximum, built from a launch template that defines the AMI, instance type and startup script. If an instance fails its health check, the group replaces it automatically.
Scaling policies
- Target tracking: keep a metric near a target, such as average CPU at 50%. The simplest and most common choice.
- Scheduled scaling: add capacity before known busy periods.
- Step scaling: add more instances the further a metric goes past a threshold.
Design rules that make scaling work
- Keep servers stateless: store sessions and uploads in a database, cache or S3, not on the instance disk.
- Make instances ready automatically through the launch template or a container image, with no manual steps.
- Set a sensible health check grace period so new instances are not killed while still starting.
A practice lab
Create a launch template that installs a simple web server, an Auto Scaling group with minimum 2 and maximum 4 instances across two Availability Zones, and an ALB in front. Stop one instance and watch it get replaced. Delete everything afterwards to avoid charges.
Related: AWS EC2 for beginners, AWS VPC basics and AWS CloudWatch basics.
Hands-on labs like this are part of our AWS and DevOps course in Bangalore.
Book a free demo class at our BTM Layout centre, and ask a counsellor for batch details.
