This article will discuss the pricing details for EC2 instances in Amazon EC2.
AWS provides multiple ways to pay for your EC2 instances. And no, I’m not talking about what kind of credit card you want to use. I’m referring to the pricing plans.
AWS provides three pricing plans: on-demand, spot requests and reserved instances.
I will discuss all three below and show you when to choose one over the others.
The first, and likely the most used one, is on-demand pricing. This option allows you to use compute power by hour without putting you in a long term commitment. This is a fixed rate per hour and saves you from losing yourself in the details. When you start using an EC2 instance using on-demand pricing, you know instantly what the cost will be if you are going to use that instance for 50 hours or for 1800 hours.
As the name implies, AWS will exert their best effort to have that resource available when you need it. Although very unlikely, it’s possible that during high demand intervals, the launching of the instance will not be possible for a short time.
A few of the reasons why you should use this pricing plan include:
- * Relatively low cost and high flexibility with regards to possible commitments to AWS
- * You have applications that are not predictable with regards to computing power needed.
How do you launch an EC2 instance using on-demand? It is very simple.
From the EC2 Dashboard, if you click on Launch Instance, AWS will assume that you want to use on-demand. Once you click that button, you will be guided to the instance configuration. You can review how to launch an EC2 instance here: Translating your Windows/Linux server skills for the cloud: How to Deploy a Server in Amazon AWS.
The next EC2 pricing plan is Reserved Instances. This plan requires that you make an upfront payment for 1 or 3 years for the EC2 instance or instances. However, after that, every time you launch an instance, the rate per hour becomes considerably lower than the normal rate for an on-demand instance.
One difference between Reserved Instances and On-demand Instances is that you can always start your instances with the former. AWS guarantees you that you can always use the instances you reserved. When you take the option of Reserved Instances, you will have to specify what kind of operating system you want and in which Availability Zone you want it.
After you purchased your Reserved Instances, additional changes will increase your costs. There are a few changes that are free, such as: moving the instance from one Availability Zone to another within the same region; and changing the instance type to another one from the same instance family.
There are three types of Reserved Instances: light, medium and heavy. The only difference between them is how much you pay upfront and how much you pay per hour after that. Basically, the light reservation means a lower upfront fee, the heavy reservation means lower rate per hour and medium is in between. There are online calculators that can help you choose the best instance type based on your needs.
There is no difference between the functionalities that a light, medium or heavy reserved instance has. It’s just about how much you want to pay upfront and per hour.
You should choose Reserved Instances if:
- * You have applications with predictable usage.
- * You want to make sure that you can start your instances at any time.
How to purchase Reserved Instances? Again, from the EC2 Dashboard, from the left menu, under INSTANCES, click on Reserved Instances, then click on Purchase Reserved Instances:
You will be presented with a few options regarding your reserved instances. In this specific case, I chose:
- * Platform – Linux
- * Instance type – m3.2xlarge
- * Availability Zone – us-east-1a
- * Term – 1 year
- * Tenancy – Default
- * Offering Type – Heavy Utilization
While we discussed almost all parameters, we didn’t discuss Tenancy yet. By using Default, AWS will start your instances on the same servers where other customers’ instances are running. The other option is to use Dedicated, which means that AWS will reserve a physical server for you and you will be the only one who will have instances running there. Of course, the price that you need to pay will go up.
Once I selected all parameters, I can check if I can purchase Reserved Instances by clicking on Search:
As you can see, one instance will have an upfront fee of $1,772 and a $0.146/hour fee.
Let’s see how much it will cost to have an instance using Light Utilization:
As you can see, the upfront fee decreased, but the per hour rate increased.
Once you add the instance to your shopping cart, you can go ahead and purchase the instance:
The third and last EC2 instance purchase plan is Spot Instances. This method allows a user to buy compute power without any upfront payment and possibly lower per hour rates than the On-Demand alternative.
Spot Instances gives you the option to specify how much you are willing to pay for an instance. As you can imagine, there are times when there is not a high enough demand for EC2 instances. What AWS does is it lowers the price of each instance type. This is called the Spot Price. You would have to pay at least this price to run an instance. If the demand increases, then the Spot Price will go up. If the price that you bid goes lower than the Spot Price, then your instances will be shutdown.
The mechanism behind using Spot Instances is the following: you put a Spot Instance request specifying the type of instance, the availability zone, how many instances you want to start, and the maximum rate per hour per instance that you want to pay.
As long as your bid is lower than the Spot Price, your instances will not start and you have the option when you make your request that your instances should start continuously if your price goes lower and higher than the Spot Price.
AWS allows you to see up to a 90-day history of the Spot Price for each instance type in multiple availability zones. Based on this, you can set your bid price more properly.
Why would you use Spot Instances?
- * You have applications that have no fixed start and end dates.
- * You need high additional computing power quickly.
This is how you can use Spot Instances. From the EC2 Dashboard, from the left menu, under INSTANCES, click on Spot Requests:
Let’s click on Pricing History to see the Spot Price for m3.medium Linux instance in us-east-1a availability zone for the last day:
As you can see, on July 1st 2014, 10:59PM, the Spot Price was $0.4520 per hour. Also, the Spot Price didn’t change too much.
Let’s see how you can actually bid for a Spot Instance. Click on Request Spot Instances and you will be asked what AMI you want to use. Select any of them and go to the next step:
Select the instance type and move further to Configure Instance Details. As you can see, you cannot use any instance type:
You can now see the Spot Prices for three availability zones and you are asked to put your bid price. If I bid higher than $0.452 (the Spot Price for us-east-1a), then my instance will start for sure. If I bid a lower value, I might need to wait for the demand to go lower so that my bid price will be higher than the Spot Price. I will use $0.300 and click Review and Launch:
A final confirmation Requesting Spot Instances will be made before the instance is created.
After the instance is created, because the bid price is lower than the Spot Price, the instance will be in pending-evaluation status until the Spot Price becomes lower than my bid price:
EC2 instances pricing is somewhat complex, but it’s like this because it offers great flexibility to the user.
Once you know exactly how much computing power you need and how long you’ll need it, you can confidently choose the most appropriate plan.