Understanding the EC2 Billing Model
May 4, 2020
Lets try to wrap our heads around how we get charged for EC2 by AWS
It does not come up nearly as often as the “Unexpected cloud bill, help!” posts (and I hope I never see the day where I end up making one such post), but still AWS can be confusing with how they get your money. The services you use can be daunting enough, never mind figuring out how you get charged for things. In this post, I hope to try and clarify how some things work with regards billing on AWS, while simultaneously stating that I am not responsible for any mishaps arising from this post. Well then, onwards!
Let us start with billable components. If you are getting started with AWS and have some basic server experience or none, your first objective is probably to launch a basic server. Maybe you are looking to set up a LAMP stack or even a simple WordPress instance. You probably have the free tier offer, so you will be creating a T2.Micro instance. This is generally your first ever EC2 instance and you feel happy afterwards normally! But let us take a more abstract view and see what we can be charged for by AWS.
- Compute – We will call the actual instance itself, with the associated vCPUs and RAM the Compute component here. This is generally what everyone sees first when they look at the pricing page on EC2. What you get charged here will vary based on instance size and underlying operating system, but it is usually an hourly rate that is rounded to the nearest second provided the minimum amount of usage time is met.
- Storage – You rarely directly interact with this service, but you did possibly go by it in your getting started tutorial, EBS. Elastic Block Store, or EBS is directly attached storage to your Instance and you will generally always have one of these volumes associated with an instance. These volumes have different types based on what storage you need and are usually billed in GB-months. (note – some instance types will have local storage options associated with them, they do not get charged for separately but naturally are considered ephemeral, so don’t store anything too valuable on those drives or instead have them safely backed up!).
- Networking – When it comes to networking, there are several intricacies. Generally, though it boils down to these three items. Data coming into your instance is always free. Data out to the public Internet is charged at a per GB rate. Inter Data transfer between AWS services ranges from free to being slightly cheaper than data out the internet and is dependent on what service and where physically the service you are interacting to is in the AWS cloud in relation to your service. If you enter the realm of load balancing, you will also see additional charges for load balancers and more networking metrics to get billed on in the form of LCUs.
- Bonus Item, AMIs – If you are using something like Ubuntu 18.04, you will not ever come across this. But as you start roaming the AWS marketplace, you will come across paid for options for your AMI. These vary in price but are generally in addition to your EC2 usage.
Thanks to the free tier, if you stay within its limits, you will not encounter a lot of these charges for your first year on AWS. However, it is important to keep these in mind as you are estimating what your footprint will cost you. One other item that comes up is the different ways you can get billed for EC2 or as I referred to it earlier, your Compute. AWS have a variety of means of using and getting charged for EC2. But these means only focus on Compute. If you are looking at a reserved instance with AWS, that fee is just for compute, not your storage or networking which you will continue to get billed at for the normal rate.
- On Demand – This is the simplest way of using EC2. You just spin compute up and down as you need to with little regard as to lock in or long-term use. As a result of this flexibility, this model is perhaps the most expensive but depending on where you are coming from, is comparatively cheap processing power.
- Reserved Instances – If you got long term usage of up to a year or three, you could purchase reserved instances to greatly reduce your month to month bill. There’s a few more items to consider when purchasing a reserved instance, but the basic idea you need is that this is something to consider when you know you will be running a certain sized footprint for the long term.
- Spot Instances – Like to live on the edge? Spot Instances are to an extent, ephemeral instances. Under the hood, they are regular EC2 instances but are just part of the unused capacity within an AWS availability zone. I guess naturally as a data centre operator, AWS want to have as much utilisation as possible to pay the bills. So, they massively discount these instances on their hourly rate. In return for this discount, if demand picks up in an AZ for say On Demand instances, AWS can terminate spot instances to have that capacity back for regular usage. There is a lot more going on here, but if your workload can handle interruption as described, Spot can be an amazing way to run heavy duty instances for unbelievably cheap.
- Scheduled Instances – I will not touch on this too much as to be honest I have never used these. But if you have workloads that only run at night or on another schedule, you can use these instances to spin up and down as needed over the long term.
Something that I see folks trip up a lot on, is that Reserved Instances are a special kind of instance you create. That is very much not the case and I think it is just due to the wording of it (you see AWS moving away from these anyway with their new Savings Plans). It is just a billing concept at the end of the day. Let me give a simple example. AWS look at my account today and they see nine instances running, seven T3.Nanos and two T3.Mediums. Assuming absolutely nothing as regards my billing configuration, these will all get charged at standard, On Demand rates for the Compute, Storage, Networking, etc. Now, I am optimising my monthly costs and I know that six of those T3.Nanos will be running 24/7. So, I purchase six Reserved Instances at an All Upfront configuration for 12 months. Now, when AWS look at my account, they still see the nine instances total, but they also see the Reserved Instances I purchased. Remember – it is just a billing concept, all the same instances here. So, what it means is that they use the Reserved Instances first, to arrive at one T3.Nano and two T3.Mediums that require On Demand billing. The Storage, Networking, etc for all my instances continue to get billed at the standard rates.
This post could be much longer than it already is, I did not even touch on the different types of Reserved Instances or the new Savings Plans. But I do hope it at the very least helps you to understand what metrics you can expect to pay on with EC2 instances and helps you conceptually understand the Reserved Instance model.
Thank you!
You could of consumed content on any website, but you went ahead and consumed my content, so I'm very grateful! If you liked this, then you might like this other piece of content I worked on.
How I monitor my cloud costsPhotographer
I've no real claim to fame when it comes to good photos, so it's why the header photo for this post was shot by Taylor Vick . You can find some more photos from them on Unsplash. Unsplash is a great place to source photos for your website, presentation and more! But it wouldn't be anything without the photographers who put in the work.
Find Them On UnsplashSupport what I do
I write for the love and passion I have for technology. Just reading and sharing my articles is more than enough. But if you want to offer more direct support, then you can support the running costs of my website by donating via Stripe. Only do so if you feel I have truly delivered value, but as I said, your readership is more than enough already. Thank you :)
Support My Work