Mastering AWS Instance Pricing: A Guide to Choosing the Right Plan for Your Needs
Tags: aws, awspricing, ec2, costoptimization
Published: 2024-04-04 01:30:30

This post serves as an essential guide for AWS cloud engineers, technical teams, project managers, executives and decision makers, legal and compliance teams, providing a detailed outline of the foundational knowledge required to set up AWS instances.

I can recollect when I just started out with AWS services; using EC2 instances to facilitate app deployments. I created an instance without understanding the cost implications, and I learnt a lesson from then on which has stucked with me. It led me to getting myself acquainted with the various AWS pricing policies towards EC2 instances.
And I plead, do not create an AWS instance without first understanding what is stated in this guide.

Now, AWS instance pricings are categorized into five
- 1. On demand instance
- 2. Reserved instance
- 3. Spot instance
- 4. Dedicated hosts
- 5. Dedicated instance

**On Demand Instance**
Simply put, on demand instances are instances where you have to pay in usage per seconds while the instance is in use. This is ideal for deployments with no long term commitments, and a defined time usage, as it is used a timely fashion with a fixed prize. With on demand instances, you have full control over the instance entire lifecycle, you can start, stop, reboot, hibernate or reboot it. See in details the pricing for each instance type on hourly bases [here](https://aws.amazon.com/ec2/pricing/on-demand/)

**Reserved Instance**
Stick with me, as this one is kind of tricky to grasp. But I will explain in simple terms.
Let's assume you needed to use a workspace within a definite timeframe, where you have to pay a fixed price hourly, but the workspace also offers a long term commitment plan which enables you reserve a slot at the workspace for over a period of time. 
That's just a simple illustration but keep it in mind. Let's understand this in the right context. 
With Reserved instance, you make a reservation for the usage of an instance over a period of time. In return AWS offers a discount on the hourly charge compared to an on-demand instance. 
The timeframe for a reservation is either one year or three years.

I would also like to point out some points about RIs 👇👇

>_A reserved instance cannot be cancelled after purchase, but you can either modify, exchange or sell the RI. This also depends on the RI offering class you choose;_
> _Standard RIs offer a bigger discount but cannot be exchanged. Convertible RIs have a smaller discount but can be exchanged for different instance types._

**Spot instance**
Again, in simplest terms, spot instances are unused EC2 instances that can be purchased with a higher discount (up to 90%) of the on-demand instance prize.
Although this perk comes with its pros and cons.
When you request for a spot instance, a _**spot instance request**_ is made. This request basically checks if your _**bid prize**_ matches the _**spot prize**_ of an unused instance in the AZ and region. When a capacity is available, your request is fulfilled.

> _**Spot prize** refers to the prize of the unused EC2 instance which also fluctuates according to the demand and supply of spot instances in that AZ and region._

**What are the pros of purchasing a spot instance?**
👉 It is very cost-effective than on-demand prizing allowing you to save more money on your computing resources.
👉 Very suitable for fault tolerant deployments that are stateless and can easily be restarted.
**The cons?**
👉 Spot instances can be terminated after a two minutes interruption notice if the spot prize for that instance exceeds your bid prize.
👉 The prize spot of an instance is unpredictable making it a challenge to budget your computing costs
👉 Spot instances requires additional planning and management to ensure that your deployment can handle interruptions. Which involves plugging into the _**EC2 instance rebalance recommendation**_ feature. This feature can be accessed from the _**instance metadata service**_ or _**amazon eventbridge notification**_. With this feature, your application is notified if it's at an elevated risk of being terminated, an interruption notice is sent sooner than 2 minutes before it is terminated.

**Dedicated hosts**
According to the [aws guide](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-hosts-overview.html), "An Amazon EC2 Dedicated Host is a physical server that is fully dedicated for your use." 
To illustrate this, its like renting out a whole restaurant for just your party. 
With dedicated hosts, you have full control over the entire physical server.
You may ask "why will I need a dedicated host if I can also achieve the same isolation using _**dedicated vpc tenants**_". Unlike dedicated vpc tenants, dedicated hosts allows you to 
👉 Use your software licenses (_**Bring Your Own License (BYOL)**_), ensuring compliance
👉 Share your instance capacity with other accounts and more

But before you consider using dedicated hosts, [here is a list of restrictions associated with dedicated hosts](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/dedicated-hosts-overview.html#dedicated-hosts-limitations)

**Dedicated instances**
Basically, a dedicated Instance is an EC2 instance that runs on a hardware that's dedicated to a single AWS account. Using dedicated Instance, you loose the benefits of launching your EC2 instances on the same host. 

---

Now we understand the various instance pricing options, lets quickly recap the use cases of these pricing options to help you make better decisions when launching your next instance.

---

**_On-demand instance_** 👌 Suitable for unpredictable workloads that will be used within a short timeframe 
_**Reserved instances**_ 👌 Suitable for workloads with steady and predictable traffic over a long period
**_Spot instances_** 👌 Suitable for fault-tolerant workloads or batch processing jobs that can be stopped without loss of state or data
_**Dedicated hosts**_ 👌 Suitable for compliance requirements that mandates physical isolation of instances, full control over instance placement and visibility of sockets, cores, and host ID
_**Dedicated instances**_👌 Suitable for compliance requirements where visibility and control over instance placement is not required.

---

We draw the curtain here. I hope you found this post informative and helpful, thank you for staying till the end. 
What instance pricing option are you choosing for your next EC2 deployment and why? Let me know in the comments.