Recently, I set up a small full-stack application on AWS to understand how an application can scale automatically when traffic increases.
My application uses:
- PostgreSQL for the database
I deployed the application on Amazon EC2 and used an Application Load Balancer (ALB) together with an Auto Scaling Group to make the infrastructure more scalable and highly available.
The Architecture
The main idea was straightforward:
Users
↓
Application Load Balancer
↓
Auto Scaling Group
↓
EC2 Instances running the application
The Application Load Balancer receives incoming traffic and distributes it across healthy EC2 instances.
The Auto Scaling Group manages the EC2 instances. I configured a minimum capacity of 1 instance and a maximum capacity of 4 instances. When the configured scaling conditions are met, AWS can automatically launch additional EC2 instances. When traffic decreases, it can also reduce the number of running instances based on the scaling policy.
My Setup
The application was deployed using EC2 launch templates so that new instances could start with the required configuration.
The important AWS components were:
- Application Load Balancer
- CloudWatch monitoring and metrics
The Auto Scaling Group keeps the desired number of instances running, while the ALB routes requests only to healthy targets.
Testing the Auto Scaling
To test the setup, I sent a large number of requests to the Application Load Balancer using the hey load testing tool.
The goal was to simulate increased traffic and monitor how the infrastructure responded.
One thing I learned during the test is that simply setting the maximum capacity to 4 does not automatically create four instances.
For example:
Minimum capacity: 1
Desired capacity: 1
Maximum capacity: 4
This only defines the allowed range. A proper scaling policy is still required to tell AWS when to increase or decrease the number of instances.
Another important lesson was choosing the right scaling metric. A simple Nginx or lightweight web application may not use much CPU even when handling many requests. Because of that, CPU-based scaling might not always trigger during testing.
Using metrics related to Application Load Balancer traffic, such as request count per target, can be more useful for this type of experiment.
What I Learned
This project gave me a much better understanding of how AWS handles scalable infrastructure.
I learned how:
- An Application Load Balancer distributes incoming traffic
- Target Groups perform health checks on instances
- Auto Scaling Groups maintain the desired capacity
- Scaling policies decide when to add or remove instances
- CloudWatch metrics help monitor infrastructure performance
- Launch Templates make it easier to create consistently configured EC2 instances
Final Thoughts
This was a hands-on learning project, but it helped me understand an important part of modern cloud infrastructure.
Building an application is only one part of the process. The infrastructure also needs to handle increasing traffic, failures, and changing workloads.
AWS Auto Scaling and Application Load Balancers make it possible to build systems that can respond dynamically instead of manually launching and managing every server.
My next step is to improve this architecture further by adding better monitoring, deployment automation, and a more production-ready database setup.
Loading article