Fatherhood in motion. Stories and experiences of a first time dad, twice, all while trying to get to the finish line.

How I run my blog on AWS

One of the reasons it took me so long to actually start this blog – besides having the time to actually write for it – was that setting up a web server and keeping it up and running seemed like such an ordeal. I remember setting up a tomcat server back in college with a static IP that was an absolute nightmare. Thankfully, I discovered Amazon Web Services and realized how easy it can be to run a site. My setup isn’t as optimal as I know it could be, but considering it’s run without any downtime for over two years, I’m pretty happy with it.

This site survived my wave of traffic after getting linked to on Lifehacker and HackerNews without any incident thanks to the scaling power of AWS. Considering how simple the setup really is, it’s a bit amazing. My first attempt at a site was run off of my desktop computer in college with a static IP I set up through the school’s network. I ran a tomcat server manually on it with no monitoring so it would often be down or unreachable for days without knowing. It’s no wonder I never developed a consistent following. Every time the computer restarted it would also get a new IP assigned and break the site. Java upgrades also broke it often and my choice to write pure html served via the only web templating language I knew at the time, PHP, was questionable at best. It’s nice to have emerged from the dark ages.

After using AWS at work for so long, I felt comfortable and familiar enough with it to try out running a site again. And I failed again. I decided to run an elastic beantalk site with Java because I was familiar with it. When I continuously broke it through my own fault, I realized it was time to offload the platform to people who knew it better than myself. Rather than worrying about the web platform and managing my own content, I’d embrace WordPress and let AWS manage my hardware and scaling. I’d even use what I’d learn from building highly available systems to make sure my site could stay up and running.

I began with the free t2.micro EC2 instance that is free with the free tier for AWS. I quickly realized I’d need a bit more power though when my first post hit and the CPU needed just to pull the content was hitting the limit. Instead, I moved onto a t2.small which gave plenty of power and headroom to grow traffic. I booted it up with the Bitnami image for WordPress available in the AWS Marketplace which made setup and configuration a breeze. Within 15 minutes – most of it playing with templates and colors – I had my site running. Once I was happy with it I booked a reserved instance to save money over the year since I knew it’d always be running.

I added a second instance, using the same snapshot I took from the first to ensure there was redundancy in case the primary instance failed, got overloaded, or just needed to be upgraded. On the off chance the datacenter went offline, I could still serve traffic. I added a load balancer in front of these with simple routing between them so that traffic would be pretty evenly distributed. I also added health checks on each so that the LB would cut off traffic to either instance in case of an issue so visitors wouldn’t see errors. I also added several monitors to send me texts and emails if the CPU usage went above a threshold or the disk began filling up.

To really make sure I was prepared for even the biggest traffic spikes, I added an auto-scaling configuration to add more EC2 instances with my snapshot image if the CPU on any host began running over a threshold consistently. I still haven’t come close to this, but it’s good to know that if I get linked to from a high traffic site, I will handle it.

Finally, and perhaps most exciting for me, was registering my domain name. I had never had a real domain name before because of the hassle of maintaining the name server configuration, but AWS made this easy as well. Using Route53, I was able to quickly buy the domain name, point it to my load balancer, and see my newly live site. I even had the option to route traffic with Route53’s DNS to different instances based on geography if I wanted to. I added more healthcheck alarms here so that I’d instantly know if my site was experiencing any issues. Because of this reliable configuration, it still hasn’t.

Setting up my blog with AWS was so easy I basically had it up and running in a night. Even with my own domain name, it was quick and incredibly affordable to set up and run. Most services are used infrequently enough that I qualify for the free tier still, though I hope continued traffic growth actually gets me past that soon. Not only has the site stayed up and available, I know the architecture is resilient and self-healing enough that if an issue does occur, most visitors won’t even notice it because of the resiliency. I also have it set up to take periodic snapshots, so even if it breaks horribly, I can quickly restore it.

If AWS had existed when I was in college, I would have built my site so much earlier. All the concerns I had with cost and reliability were easily mitigated with AWS. It simplified things to the point where I simply don’t even think about it running now and know that if something does happen, I’ll know, but it will also take care of itself. And for a busy person, that self-healing is critical because who knows when I’d actually have time to fix it. It really couldn’t be easier.a