Optimizing costs can be difficult because AWS offers several different types of pricing models. In order to make sure that you are paying the least amount possible while still obtaining the level of resource availability that your applications require, you need to understand Amazon EC2’s pricing options and identify which type of pricing is best for each workload that you host.
This article explains how pricing works on EC2 and offers suggestions for optimizing EC2 costs.
Should You Use EC2 at All?
First, let’s consider the biggest question: Is EC2 a more cost-effective hosting solution than relying on a private cloud or on-premise servers?
In many cases, the answer is yes. Setting up and maintaining more than a handful of on-premise servers will require you to hire an in-house IT staff, or outsource your IT management to a company that will charge significantly for the service. By moving your workloads to EC2, you avoid these costs (although you will still require some IT help because you need someone who will be able to manage EC2 instances for you; EC2 is not a fully managed service).
Consider also that EC2 allows you to avoid capital expenditures on IT hardware. Deploying on-premise infrastructure requires a large upfront investment in server hardware, in addition to ongoing maintenance costs. With Amazon EC2, you simply pay monthly service fees, rather than having to expend capital (and possibly pay associated finance costs, if you lack the cash to make the purchases) on server hardware.
EC2 Instance Pricing Overview
In general, the more resources you consume on EC2, the more you pay. That part of EC2 pricing is easy to understand.
However, the sum of money that you pay to consume a certain amount of resources can vary greatly depending on which type of EC2 pricing model you use. That is why it is important to understand each of the EC2 pricing models, which are described below.
EC2’s on-demand pricing model is the most basic type of EC2 pricing. With on-demand pricing, your EC2 instances have immediate access to as much compute, memory and storage as you need, even if their resource requirements fluctuate frequently.
You pay only for the amount of resources that you actually use. Thus, if your EC2 instance consumes a large amount of compute for a few hours per day, but less compute at other times, your costs will vary proportionally.
The major downside of on-demand pricing is that it is more expensive than most other EC2 pricing models because it does not provide an opportunity to gain a discount. However, on-demand pricing is the most easily managed and predictable type of pricing, especially for applications that experience constant fluctuations in demand, such as high-traffic Web servers.
Spot Instance Pricing
Spot instances, unlike on-demand pricing, can provide significant discounts for EC2 costs.
With spot instances, you can issue a bid to purchase EC2 resources at a discounted rate. Discounts can be as high as 90 percent off of the equivalent on-demand pricing.
The size of the discount, as well as the likelihood of winning your bid, vary depending on the level of demand that exists for resources on EC2 at a given moment.
The advantage of spot instances is cost savings, which, again, can be very significant if you bid at the right time. The disadvantage is that, in order to take good advantage of spot instance pricing, you have to bid on spot instances at a time when discounts are high. You also have no way of knowing whether your bid will be accepted. (AWS provides a tool called Bid Advisor to help you plan spot instance bids, which is useful if you wish to take advantage of spot instance pricing, but there is still no way to predict with certainty when spot instances will be at the lowest price.)
Spot instance pricing is not a good option for Amazon EC2 workloads that you run an on an ongoing basis because spot instances are less predictable, and the work required to bid on spot instances is significant. If you manage a large number of EC2 instances, it is simply not realistic to attempt to take advantage of spot-instance pricing for all of them.
However, if you know that you are going to host a particularly resource-intensive workload for a temporary period and have flexibility regarding when that workload is run, or if you have free time available to bid on spot instances, this pricing model can deliver the greatest EC2 cost savings.
Reserved Instance Pricing
Reserved instances are another way to obtain a pricing discount on EC2. When you choose a reserved instance, you purchase a certain amount of EC2 resources ahead of time.
Reserved-instance rates are lower than on-demand pricing, although the discounts are not as great as those of spot instances. Reserved instances provide discounts of up to 75 percent compared to on-demand instances, rather than the 90 percent discounts of spot instances.
Reserved instances are, however, more convenient and predictable than spot instances because you do not have to invest time in bidding on a reserved instance, or trying to predict when prices will be lowest. Once you purchase a reserved instance, you have guaranteed access to EC2 resources at a set price.
The major disadvantage of reserved instance pricing is that the amount of resources you can consume under this pricing model is limited. For this reason, reserved instance pricing is not good for workloads that are likely to experience spikes in demand or that may require more resources than you anticipate.
Reserved instance pricing works well for EC2 workloads whose resource consumption is predictable and consistent. For example, if you need to perform a steady stream of compute operations for data analytics, reserved pricing is likely to be the most cost-efficient option.
Dedicated Host Pricing
EC2’s fourth pricing model is dedicated host pricing. When you purchase a dedicated host, you get exclusive access to a physical server in the AWS cloud. In other words, you do not have to share the server with other users, as you would with other types of EC2 instances.
In general, dedicated host pricing is the most expensive type of EC2 pricing model. However, when you use it in the right way, a dedicated host can save you money. For example, because you get access to a physical server, you can install a commercial operating system on it using a license that you already own.
You can also use a dedicated host to run operations on bare metal, which is not possible with other EC2 instances. Using a cloud-based bare metal server for workloads that require bare metal may be less expensive overall than maintaining an on-premise server for the same purpose.
Comparison of EC2 Pricing Plans
|Best for||Apps with fluctuating demand||Maximizing cost savings||Workloads with predictable, consistent demand||Workloads that benefit from bare-metal access|
|Discounts available (compared to on-demand)||None||Up to 90 percent off||Up to 75 percent off||None (but you can potentially save on licensing fees)|
|Resource usage limitations||None||None||Reserved capacity||Server maximum capacity|
EC2 prices can vary very widely depending on which pricing model you choose. Although it would be simplest to go with on-demand pricing for all of your EC2 instances, you can save significant amounts of money by identifying workloads that are good candidates for other pricing models and taking advantage of them when appropriate.
About the author