DevOps

Understanding AWS Billing and EC2 reservations

One of the most confusing things I approached when working with AWS was the Billing. There are tools which should help, but in the beginning they were just frightening. They looked somehow random and not consistent.

My customer is running three zones with around 50 EC2 instances. Some timebased scaling is helping at prime time. A couple of instances are so called “reserved instances”.

Reserved? On-Demand?

On-Demand instances are virtual machines which run whenever you hit the “start” button. You pay the full price, which is around USD 80 for a t2.large instance.

Now, if you are sure you need that instance for one year, you can have it for ~USD 58 already. On the other hand, you have to pay for the full 12 Months, no matter if you need it or not.

With paying upfront, you can safe even more. But the difference is like save 29% or save 34%. It does not matter that much when you have “only” 50 instances and need some flexibility.

You could reserve it for three years in advance, which could safe you more than 50% from the initial cost. But hey three years! A lot can happen in these years! And when you are committed to 10 instances for each USD 40… wow. You need to be sure on what you do, and I doubt any Start-Up should reserve for that long time.

Reserved instances can keep your cost at a sane level. If somebody told you AWS is cheap, then reservation is a key factor to that.

In our case we made the decision to reserve instances which are crucial to our service. We use “On Demand” for scaling.

Monitoring reserved instances

There are some helpful tools in your Billing section to identify unused reserved instances. In example, you can find an “Reserved Instances Utilization Report” in the reports.

reserved-instance

As you can see in the above image, we have stopped a reserved instance. It’s “use rate” goes down at end of February. The report says, it is only used for 50%. We don’t use it for auto scaling, so how can they say 50%? The reason is, we have two instances and only one is in use.

In the table below the chart we can see how much we safe. So more you use the reserved instance, so more money you safe. If you don’t take care, you can loose all the benefits of reservation by starting wrong instances.

Wrong instances? Yes, your reservation is valid only when you use the instance in the same region/availability zone (!) you have reserved it.

This report is not the only one to help with monitoring your reservations.

Daily costs

There is another report, called the “Daily costs”. It is a break down of what you spend on EC2 each day. Now look at the following image.

costs-per-day

You will recognize we spent almost USD 1600 on the first day of the month, while all other days go with around USD 270. How is that possible?

This report made me think a lot. As I found out, on the first day of the months all your reserverations hit the bill. It is natural, because you have to pay it any way. I have expected the rest of my cost to be “On Demand” only.

But no. When the month progresses, the report will add the costs of reserved instances which are used to the daily cost. But the unused reserved instances will stay at the first day. In other terms: if you use all your reserved instances, your first day will look similar like all other days at the end of the month. If you don’t use all instances, you will have a peak on the first day (like us).

Here is one good thing to know. First, we didn’t use all reservations we had. The daily cost was around USD 80. We corrected our error and then we had USD 100 as daily cost. This frightened me! Until I realized, that the costs would just be distributed on the various days and reduced from the first day.

EC2 Instance Usage

Another great report is the instance usage report.

used-instance

If you group it with “Purchase Option” you can see how much you spend on reserved vs on demand instances. In the above image you can see, how less we use reserverations until mid-february. Later we recognized our error and used more reservations.

The actual costs in the beginning of the month were much hight than you can see in this chart. The reason is, you only see what is USED, not what is actually causing the cost. In the early month, you could not see the additional cost of the unused instances.

Later, we used almost all reservations. This is a more accurate report to consider for the total cost. In general, you should see the number of reserved instances x 24 hours for utilization each day.

In example, if you reserved 10 instances, you should see 240 hours of utilization. If you cannot see that number, you have not used all of your reservations.

In our case, we could reduce the number of EC2 clearly, because we reused some big machines which were shutdown otherwise.

Wrap it all up

Reservation helps. So more you are “certain” about your environment, so more you can safe. But keeping an oversight is hard.

The most important thing to know is: the reports all update dynamically. My best advise to you is to check the reports often, almost daily in the beginning. I did that, and it helped to let me understand the reports better.

You need to check the usage reports, if reserved instances are used. It is crucial. As long as you actually use your reserved instances, you should be on the safe side.

Finally: you need to find a balance between “I want to keep it forever”, “I can take it for a year” and “I need flexibility”. As everything in life, Flexibility comes with a higher cost.

Reference: Understanding AWS Billing and EC2 reservations from our JCG partner Christian Grobmeier at the PHP und Java Entwickler blog.

Christian Grobmeier

Christian is a passionated software developer, architect and trainer. He is a member and VP of the Apache Software Foundation, working on projects like Struts, log4j and others. He founded Time & Bill and constantly tries out new ideas.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button