Tuesday, May 28, 2013

Amazon AWS, Should I choose a reserved or OnDemand EC2 instance?

Well I'm glad you ask. I set out to answer the same question for our mobile app backend servers. Our mobile app currently runs on two Medium EC2 instances along with several other services like RDS, S3, and SES. We also have 1 micro development server, and 1 micro test server. Setting this all up can be a real challenge but figuring out how much it's all going to cost you is nothing short of rocket surgery.
Reserved vs. OnDemand EC2 AWS instances Cost Analysis

As you may already know, much of your AWS bill is going to come from your EC2 instances (Amazon Elastic Compute Cloud). Now Amazon gives you this nifty "simple" calculator to use to determine what your total cost is going to be but if you're like me, that's only going to confuse you more than help. To further complicated things, Amazon gives you several choices on how you can consume these instance:

  • On Demand - "pay for compute capacity by the hour with no long-term commitments"
  • Spot - "bid for unused Amazon EC2 capacity" and save upto 50+% but variable availability.
  • Reserved - make a low, one-time payment for each instance you want to reserve and in turn receive a significant discount on the hourly charge for that instance. This reserved option comes with several options of it's own based on how much you want to use the thing.
    • Low Utilization
    • Medium Utilization
    • High Utilization


The trouble is you now need to answer some tough questions. What do I need this instance for? How much utilization do I need (how much uptime)? And how long am I willing to commit for? I had these same questions but wanted a way to see all the hard dollars before I made a decision. In the case of our app, I know I'll need the two medium instances for at least the next 5-6 months and potentially longer. As for the Micro instances, they are actually quite useful regardless of what's going on so we may use them for the entire year no matter what is happening. But is it all worth committing to a whole year?

So I took a few minutes (okay an hour) to sift through all the pricing information on the AWS pricing site and put together a spreadsheet that gave me the information I needed, mainly:

  • Compare the cost of several sizes of reserved vs. OnDemand instances over 6 and 12 months
  • Determine the % savings over 6 and 12 months  on all utilizations and sizes
  • Determine how long it would take for us to break even with the 1 year commitment.
I found some pretty neat stuff. It turns out that the reserved instances can save you upto 44% in 1 year when compared to OnDemand instances when you pick the heavy utilization option and since our app is always on we would likely choose that option. It's important to understand what AWS intended for the different utilization types. They don't mean you are getting a different kind of instance, it's just a billing scheme. You're able to get a deeper discount if you're using more, that's all. So effectively, the following savings is what you can expect:

Amazon AWS EC2 Reserved Savings over 6 and 12 months
Reserved EC2 Savings over 6 and 12 months


Another thing I found interesting was that even if you're using the instance at 100% utilization, you're better of with the light utilization option if you're only going to keep it less than 7.5 months. Haha, how did I get that number?
Well, lets say:
L= upfront cost of light utilization
c= hourly cost of light utilization

H= upfront cost of heavy utilization
h= hourly cost of heavy utilization
X= Number of hours  before it's suitable to upgrade from Light to High. 
Then:

L+(cX) = H+(hX) 

so

X= (L - H) / (h - c)

Divide that number by 720 (The number of hours in a month) and you get 7.5

As similar calculations will show that you're better off for 8.3 months on Low vs. Medium, and 6 months on Medium vs. Heavy. In other words, at full utilization:

Months before I should upgraded from

Small to Medium: 8.3 months
Small to High: 7.5 months
Medium to High: 6 months


All this actually makes the medium option a lame duck unless your needs are unique. 

So the basic lesson here is, if you're planning to keep an instance for at least 100 days (3.3 months) at full utilization, you're better off buying into the AWS reserved instance. 

Here's a link to the google spreadsheet I put together so you can do your own variation. Also note that the numbers don't apply to the micro instance the same way as they do to the other instances. 

Cheers










1 comment:

  1. Excellent article. i'm working on building a site myself. but tough to follow because will not have too much traffic for atleast 3 months

    ReplyDelete