Track Your AWS Bill and Learn How to Optimize for Cost.

It's All Fun and Games Until the Bill Comes

Cloud computing is arguably the wave of the future. Major companies like Netflix, Kellog's and even McDonalds are now using AWS to fuel their internet business objectives. This means that the average developer or system administrator is going to need to be ahead of the curve on these technologies to stay relevant in their current job or to have a chance in the job market. However, for many people they are afraid to get their feet wet with AWS because of the inevitable bill that shows up. It's well known that AWS will give you one free year to play around but that is hardly enough time to explore deep security concerns, private networking and and general best practices in the cloud. Typically after the free year most people walk away from AWS because they are just plain scared of the bill. Understanding billing is an important part of the use of cloud architecture. That's why in this post I'll show you how you keep a careful eye on your AWS bill with notifications and even how to use different instance types for massive savings over time.

Failure to Plan is Planning to Fail

There are a few ways to stay on top of your AWS bill but one of the most obvious ways is through billing notifications. I like to get billing notifications through text message because they are harder to ignore than email. The two services you need to accomplish this are CloudWatch and SNS. You can set an alarm in CloudWatch based on your bill and use it to trigger a notifications that are in turn sent to an SNS subscriber. I currently have my alarms set for $3,$10 ,$20 and $100. Here is what it looks like

From this screen shot you can see that my bill is over $3 but under $10. I can easily make another alarm for $250 by clicking create an alarm. They tricky detail here is that it makes you pick a metric before you can create the alarm. Set your metric as EstimatedCharges and be sure to select your denomination. You should be at this point

In the next step you will define the actual alarm and configure your desired action. I'm going to send myself a text message via SNS. You can take it a step further and configure autoscaling to terminate instances if you want to. My $250 alarm is now set

Saving Money on Instance Type

A central part of the AWS ecosystem are the Ec2 instances. If you are looking to save money on your bill it's worth your while to understand the configurations available with Ec2. The basic facet to understand here are the instances types. People tend to overlook these because they took some training that was all focused on getting an instance up and running and maybe serving some general purpose but they never really thought about the bill. Ec2 defaults to launching instances as on demand. This is the most flexible but it's also the most expensive. To save money on your bill you shouldn't neglect reserved and spot instances. As of October 2017 AWS has gone to billing in 1 second increments for Ec2,EBS and EMR. The key point here is the on demand rate is always higher than the reserved rate depending how you structure the term commitment. The term commitment is essentially the down payment.

Massive Savings on a Reserved Instance (An Example)

I'm currently running t2.micro instance as a reserved instance. Check it out

You can see here I paid $115 upfront for a three year term on a t2.micro instance but my but my usage and recurring charges are 0. Meanwhile if we check official on demand rates here we'll see that same t2.micro instance cost $.0116 per hour. If we apply that rate over the three year duration we quickly see that the on demand instance will cost 0.0116 * 24 * 365 * 3=$304.85. This translates to a savings of about 63%.

Saving More with Spot Instances

In our last price comparison we saw a major discount using a reserved instance. It's often said that all magic has it's price and the caveat to this magical discount was a full payment up front. The rate for a spot for instance will be even cheaper. In fact at the time of writing it is $0.0037 per hour. What is the price for this magic? The answer is instability. Spot instances allow you to bid on a rate. When an instance satisfying that rate becomes available you get the instance for that rate you bid. This can give you up to a 90% savings. However, if the rate fluctuates above your bid your instance will be terminated after a two minute notice. Most people won't tolerate instability but the typical use case of spot instances is big data analytics. This allows you to run all you analytics at the cheapest possible price.

Money Doesn't Buy Happiness ... but I had to Find Out For Myself

AWS billing is a complicated subject but what we have seen here is that it is easy to track and that a little of strategy goes a long way to cut the bill down. To protect yourself from a huge unexpected AWS bill you should consider your needs and priorities and then optimize accordingly. It takes some effort, but it's for your financial benefit.