AWS Builder Center
One Server Wasn't Enough. What Happens When Traffic Grows?

One Server Wasn't Enough. What Happens When Traffic Grows?

My app ran on a single EC2 instance, so one bad moment could take it down. Here's how Elastic Load Balancing and Auto Scaling taught me to stop relying on one server and let AWS add, remove and replace servers for me.

AI Developer
In my last post, I gave my app a proper database with Amazon RDS: automated backups, Multi-AZ failover, and tucked away in a private subnet where only my app can reach it.
My database was ready for failure.
But my app wasn't.
Because everything my users touched still ran on one EC2 instance.



The Day I Noticed the Weak Spot

I shared my app's link with a few friends so they could try it.
It worked. But when several people used it at the same time, pages started loading slowly. And a thought hit me:
What if this one instance stops right now?
Not slowly. Not partly. The whole app would just be gone.
I had spent a whole post making sure my database could survive an Availability Zone failure. Meanwhile, my web server was a single point of failure sitting in one AZ.
That didn't feel right.



My First Idea: Just Get a Bigger Server

My first instinct was to stop the instance and pick a larger instance type. More CPU, more memory, problem solved.
That's called scaling up (or vertical scaling). It helps for a while, but:
  • There's always a limit to how big one server can get.
  • It's still one server. If it fails, everything fails.
  • Changing the size usually means stopping it, which is downtime.
The other option is scaling out (or horizontal scaling): run more servers, not bigger ones.
Scaling up makes one server stronger. Scaling out makes the whole app more resilient.
But scaling out raised two new questions:
  1. If I have three servers, which one does a user go to?
  1. Who adds and removes servers as traffic changes?
Those questions have two answers: Elastic Load Balancing and Auto Scaling.



Part 1: The Load Balancer, a Front Door for Many Servers

A load balancer sits in front of my servers and spreads incoming traffic across them.
Users don't connect to an instance anymore. They connect to the load balancer, and it decides which healthy server handles each request.

Which Load Balancer?

AWS has a few types. The two I needed to understand were:
Load balancer
Works at
Best for
Application Load Balancer (ALB)
HTTP/HTTPS (Layer 7)
Web apps and APIs; can route by URL path or hostname
Network Load Balancer (NLB)
TCP/UDP (Layer 4)
Very high performance, non-HTTP traffic, static IPs
My app is a website, so I chose an ALB.

The Pieces of an ALB

Like every service in this series, it came down to a few parts:
  • Listener: what the load balancer listens for, like HTTP on port 80 or HTTPS on 443.
  • Target group: the set of servers it sends traffic to.
  • Health checks: regular requests to each server, like  /health , to see if it's responding.
That last one was my favourite part.
If a server stops answering health checks, the load balancer stops sending it traffic. Users never land on the broken server. They don't even know it happened.
A load balancer doesn't just share traffic. It quietly steers users away from failure.

It Spans Availability Zones

An ALB is placed across at least two Availability Zones. So I put my servers in two AZs too.
Now if an entire AZ has a problem, the servers in the other AZ keep serving users. That's the same idea as Multi-AZ in RDS, applied to my web servers.



Part 2: Auto Scaling, Servers That Come and Go on Their Own

The load balancer solved where traffic goes. But I still had a fixed number of servers.
Traffic isn't fixed. It's quiet at 3 AM and busy at lunchtime. Running five servers all night wastes money. Running one server at lunch hurts users.
That's what an Auto Scaling group solves.

The Pieces of an Auto Scaling Group

1. Launch template: what does a new server look like?
A launch template stores everything I chose in my EC2 post: the AMI, instance type, security group, and the IAM role from my IAM post. Auto Scaling uses it to launch identical servers whenever it needs one.
2. Capacity: how many servers?
Three numbers control it:
  • Minimum: never fewer than this (I chose 2, one per AZ)
  • Desired: how many should run right now
  • Maximum: never more than this (a safety limit for my bill)
3. Scaling policy: when should it change?
I used a target tracking policy: "Keep average CPU around 50%."
When traffic grows and CPU rises, Auto Scaling adds servers. When traffic drops, it removes them. I don't have to watch a dashboard all day.

The Part That Surprised Me Most

Auto Scaling doesn't only scale for traffic. It also replaces unhealthy servers.
I tested it by stopping one of my instances on purpose. A few minutes later, the Auto Scaling group noticed it was unhealthy, terminated it, and launched a fresh one from the launch template.
I didn't fix anything. The system fixed itself.
Auto Scaling isn't just about growing. It's about always getting back to healthy.



How It All Fits Together

Here's my app's architecture now, built up across this series:
  1. Users connect to the Application Load Balancer in public subnets.
  1. The ALB sends traffic to healthy EC2 instances in an Auto Scaling group, across two AZs in private subnets.
  1. The instances use an IAM role to read from S3.
  1. The instances talk to RDS in private subnets, with Multi-AZ enabled.
And the security groups follow the same pattern as my RDS post:
  • The ALB allows HTTP/HTTPS from the internet.
  • The EC2 instances allow traffic only from the ALB's security group.
  • The database allows traffic only from the EC2 instances' security group.
Each layer only trusts the layer in front of it.



The Lesson I Didn't Expect: Servers Should Be Replaceable

Once servers started appearing and disappearing on their own, I had to change how I thought about them.
If a user's session or uploaded file is saved on one instance, it's lost when Auto Scaling removes that instance. Or the next request goes to a different server that doesn't have it.
So my servers had to become stateless:
  • Files go to S3
  • Data goes to RDS
  • Nothing important lives only on one server
When any server can disappear at any time, none of them can be special.



What Load Balancing Taught Me Beyond Load Balancing

Before this, I treated my EC2 instance like a pet. I named it, configured it by hand, and worried about it.
Now I see servers more like cattle: identical, replaceable, and managed as a group. That's a common way people in the cloud world describe the shift, and now I finally understand it.
The goal isn't to keep one server alive forever. It's to keep the application alive, no matter which servers come and go.



My Takeaway

My app used to depend on one server in one Availability Zone.
Now an Application Load Balancer sends users only to healthy servers, and an Auto Scaling group adds servers when traffic grows, removes them when it drops, and replaces any that fail.
The question changed from "Is my server running?" to "Does my app stay up, even when a server doesn't?"
There's just one thing left that bothers me. Users reach my app through a long, auto-generated load balancer address that nobody could remember. Next, I'm finding out what happens when you type a URL and how Route 53 and CloudFront help people find your app, quickly, from anywhere.
Stay tuned! 🚀
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article