
I Stopped Pointing DNS Straight at My EC2: What ALB Taught Me About Staying Up
How putting an Application Load Balancer in front of a single EC2 instance made deploys downtime-free, with health checks, path-based routing, and TLS termination.
For my first deploy, my setup was as simple as it gets: one EC2 instance, one public IP, and a DNS record pointing straight at it. It worked, and because it worked, I assumed it was fine.
Then I needed to deploy a fix on a Friday afternoon. I stopped the app, replaced the code, and restarted it. The whole thing took about four minutes. Four minutes does not sound like much until it is four minutes where every user sees an error page, and you are watching the clock while a service restarts. That deploy taught me something I should have learned earlier: a single instance is a single point of failure, and pointing DNS at it just makes the failure public.
That was when I put an Application Load Balancer in front of it, and it changed how I think about staying up.
The load balancer is not just for load
The name fooled me at first. I thought a load balancer was something you added when traffic got big, to spread requests across many servers. My app was small. I had one instance. Why would I need one?
The real value, for me, was not spreading load. It was having something stable in front of something that changes. The ALB has a DNS name that never changes, and behind it sits a target group: the list of instances currently allowed to receive traffic. When I deploy now, I can add a new instance to the target group, wait until it is healthy, and only then remove the old one. Users never see the gap. The deploy that used to take my site down for four minutes now takes it down for zero.
That shift in thinking matters more than the feature list. DNS points at the load balancer, which is designed to stay put. Instances come and go behind it. My app stopped being tied to one machine with one IP, and that separation is what made deploys boring instead of scary.
Health checks are the part that actually saves you
The second surprise was health checks, and they are the feature I now refuse to run without. A target group does not just list instances. It keeps asking each one, on a path I choose, whether it is actually ready to serve traffic.
I learned why that matters the hard way. Once, an instance booted fine and the app process started, but the app was stuck waiting on a database connection that never came back. From the outside, the server looked alive. Inside, it could not answer a single request. Without health checks, the load balancer would have kept sending users to a dead app. With them, the instance failed its checks, was pulled out of rotation, and traffic went to the healthy one. No one had to page me at 2am to notice.
The lesson is to pick a health check path that proves the app works, not just that the server is on. A simple root path that returns 200 is fine if your app is simple. For mine, I use a dedicated health endpoint that checks the database connection too. If the database is down, the instance honestly reports unhealthy, and the load balancer stops trusting it. A health check that always says yes is just decoration.
There is a small detail worth getting right here: the interval and the threshold. Check too often and a brief hiccup pulls a healthy instance out of rotation. Check too rarely and a dead instance keeps getting traffic for minutes. I started with the defaults, watched how my app behaved under a real deploy, and tuned from there. Defaults are a starting point, not a decision.
One entry point, many small decisions
Once the ALB was in place, a few things that used to be painful became configuration instead of work.
Path-based routing was the first. Requests to /api go to the API target group, requests to everything else go to the web app. Before the ALB, that split meant running a reverse proxy on the same box as the app, or paying for a second instance. Now it is a rule on the listener, and I can change it without touching a server.
Sticky sessions were the second, and a cautionary one. My app kept a little state in memory per user, and moving a user between instances mid-session broke things. Turning on stickiness fixed it in five minutes, and that speed was also the warning: stickiness papers over state that should probably live somewhere shared, like a cache or a database. I use it now only as a bridge while I move state out of the instance, not as a permanent design.
The third was TLS termination. The ALB holds the certificate and talks HTTPS to users, while traffic behind it stays inside my VPC. Setting that up in the console took less time than I had spent renewing a certificate by hand on a single server the year before. ACM handles renewal, and I stopped thinking about expiry dates entirely.
None of this makes my app faster. It makes it survivable: deploys without downtime, dead instances removed automatically, and one stable front door no matter how many instances sit behind it.
My takeaway
I used to think a load balancer was a scaling tool for big systems. It turned out to be a reliability tool for small ones. The moment I had something users depended on, even a little, I needed a layer that could swap instances in and out without anyone noticing.
If your DNS still points at a single EC2 instance, that instance is not just your server. It is your deploy window, your failure domain, and your 2am page, all in one box.
What is the one deploy you still dread, and what would change if the server behind it could be replaced without anyone noticing?
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article