Amazon Web Services makes it easy to host servers in the cloud. Almost too easy. With just a few button clicks, you are spending thousands a year. You usually have a production environment and a stage environment. Then you might have a couple development environments. Each new project gets their own servers. It starts adding up quickly without noticing, especially if you aren’t the one paying the bill. Most of these servers sit around for months or years, and you could be paying more than you should be if you aren’t taking advantage of reserved instances.
By default when you create an EC2 instance, you are paying for an on-demand instance, and you pay a premium for those. They are intended to be used when you are under high-load, or when you just need a temporary server for a short amount of time. But since this is the default, these get used for everything.
To make use of reserved instances, you need to do a bit of homework. Reserved instances are available in 1 or 3 year terms, and are specific to a certain instance type, region, and availability zone. You will be paying for this instance 24/7 for the entire reservation period whether you are using it or not but the cost savings are massive, currently ranging from 26% to 75%.
There is an important distinction to make here. When you buy a reservation, you aren’t actually creating another server. These are only used for billing, and you just launch EC2 instances like you normally do. Amazon also guarantees they will have capacity available if you have unused reservations, as the name implies. When you receive your bill, Amazon automatically determines which instances to charge at the on-demand rate, and which to charge at the reserved rate. This means that a reserved instance is not tied to a particular EC2 instance. You could buy a single reservation, then create and terminate a new EC2 instance every day for a year and the reservation would still apply to all of those instances as long as they never overlapped and were the same type. There are also a couple more features that make this even easier.
Modifying Instance Size
One of the first questions I was asked was “What if I need to scale up?”. Amazon is very flexible and allows you to change the instance size of reservations, as long as the total amount of computing power stays the same. For example, if you are running a production server on a t2.small, and determine you need to scale up to a t2.medium (twice the computing power) you are able to combine 2 reservations for a t2.small (buying another if needed) and convert it to a single reservation for a t2.medium.
Changing Availability Zones
You are free to change the availability zone of a reserved instance at any time, for no cost. I am actually disappointed that you have to select an availability zone at all when you reserve an instance. Since you can change it at any time, this should be something that Amazon’s billing does automatically for you. Maybe this is just some backwards-compatibility cruft and it will be removed later, but currently you need to pay attention to this and make sure you have the availability zones set correctly. If not, you might get a little surprise on your next bill.
If you realize that you will no longer need a reservation, you are able to sell the instance on the Amazon marketplace. The marketplace might also be a good place to look if you want to find shorter reservations from other users.
If you have multiple accounts linked together with consolidated billing, reservation discounts can apply to any EC2 instance in any of the linked accounts.
I decided to try out reserved instances for our Incubation team and in just a few hours we are already saving thousands of dollars a year. If you want to get started yourself, here are some useful resources.
EC2 reservation pricing
Getting Started Guide
Amazon Marketplace Guide