Cloud Cost Optimization Strategies for Compute Instances
Tags: cloud, aws, optimization, tips
Published: 2017-11-16 07:37:05

---
title: "Cloud Cost Optimization Strategies for Compute Instances"
published: true
description: 
tags: Cloud, AWS, optimization, tips
---
Is the majority of your cloud monthly bill made up of instances or VMs? Most organizations pay 50-80% of their total cloud bill in compute services. This cloud bill can be reduced up to 40% if you identify the instances or virtual machines that are left unused and take advantage of discount options.

In this blog, you will learn about discounted options of cloud providers and how to leverage instances according to workload. While selecting cost-effective instances, it is very important to understand the capacity of various instances under specific requirements. Before jumping to optimization strategies, you should know how to [compare the pricing of compute services of major cloud providers] (https://www.simform.com/compute-pricing-comparison-aws-azure-googlecloud/).

##Cost Optimization Strategies to Reduce Compute Spending
The majority of spending for most users is on compute, making it a key area of focus on for cost reductions.

###Downsize Under-Utilized Instances
A downsizing of instances reduces costs up to 50 percent. Check the example below of m4.large and t2.small.

![Downsize under-utilized instances] (http://www.simform.com/wp-content/uploads/2017/09/Scale.png)

As you can see, m4.large is utilized less than 50% between midnight and 9 am. Server usage increased from 9 a.m.-2 p.m. and two m4.large instances are required to serve requests. Then, usage starts decreasing until 6 p.m. and increases in the night. As per graph, it is clear that during some specific time spans, a single m4.large instance doesn't even utilize 50% of its capacity. It costs $4.1/day.

Now we know that in a specific time span, m4.large used less than 50%, so we can use a t2.small instance, which has the half compute capacity compared to the m4.large. Here, 70 t2.small instances are required manage the workload and still, it saves more than 60% of the instance cost.

###Turn Off Unused Instances
Normally, organizations select instances according to the peak load. The problem is that this requirement is not constant and varies with time. To fully optimize cloud spending, turn instances off that are no longer being used. The image below shows how server load varies on a particular day and when to turn off instances.

![Turn-off unused instance] (http://www.simform.com/wp-content/uploads/2017/09/Scale-2.png)

As you can see, from midnight to 8 a.m., server load can be handled by one instance, so you can turn off the second instance to save the extra cost. During the next 8 hours, server load increases and requires two instances. Again, server load decreases for the last eight hours of the day, so you can turn off the second instance again.

##Use Discounted Instances
Most cloud providers have discount options for instances. Before you can accurately compare compute prices, it’s critical that you understand the discount methods.

Here, I’ve listed three major cloud providers' discount options.

###AWS Reserved Instances
AWS provides a discount in exchange for making a one-year or three-year commitment. You can get discounts from 24-75 percent, depending on the RI term, the instance type, and the region.

###Azure 12 Month Pre-Pay Instances
The primary approach to getting discounts on Azure is your Microsoft Enterprise Agreement (EA). EAs offer discounts from 15-45 percent, depending on the level of usage you commit to.

###Google Sustained Use Discounts
Google's Sustained Use Discounts (SUDs) happen automatically and require no upfront commitment. It charges an according to the percentage of usage in a month. Once instances have been running for 25 percent of the month, the price goes down to 80 percent of on-demand (a 20 percent discount), and when you hit 50 percent and 75 percent for the month, the discount goes up another 20 percent. As a result, instances running 100 percent of the time during the month will earn a maximum 30 percent discount – with discretion, as not all workloads are a good match.

##Use AWS Spot Instances, Azure Low Priority VMs, or Google Preemptible Instances
These types of discounted instances can save users a lot of money, but they should be used with discretion, as not all workloads are a good match.

###AWS Spot Instances
Using AWS Spot Instances, you can get discount of up to 90% on the on-demand EC2 instance price without paying anything in advance!

How does it work?

You set a maximal bid price and optionally a period of up to 6 hours. The price you pay is the spot price in each hour. When this price goes above your specified maximal bid price, the instance is terminated. Be careful, though! The new console for the spot instances creates a fleet, and even when terminating the instance yourself, the fleet remains open. You need to cancel the “spot request” (the fleet), as well as terminate the instance(s) when you are done. The instances are guaranteed to remain active for the specified amount of time – up to 6 hours. See the following image for a better understanding.

![AWS spot instances] (http://www.simform.com/wp-content/uploads/2017/09/Scale-2-1.png)

###Azure Low-Priority VMs
With low-priority VMs, you can take advantage of unused capacity for a great price. Low-priority Linux VMs come with an 80% discount, while Windows VMs come with 60% discount. The discount is calculated in comparison with their on-demand hourly price. The vast majority of VM sizes and types are supported to run as Low-priority VMs. The price for low-priority VMs is fixed, with each VM size now having a fixed low-priority price in addition to the existing full price. See the Azure Batch pricing page for more details.

###Google Preemptive Instances
Google preemptive instances come with a fixed discount of up to 80% of the regular cost. You can run instances for 24 hours maximum, and if the requirement increases, the preemptive instances may be shut off at any time. You can re-up every 24 hours, but the instance will still shut down and you will start from scratch with a new preemptive instance – so no long-running processes are possible here.

As compute services directly impact an organization’s performance, these cost optimization strategies should be used after analyzing workload and performance. These methods are some of the quintessential compute cost optimization techniques you can use in your regular cloud optimization tasks. Having the ability to understand your existing costs and effectively modeling changes are critical in both estimating and delivering real cost savings.

<hr>

*I have published an updated version of this post here [Cloud Cost Optimization Strategies for Compute and Storage] (https://www.simform.com/cloud-cost-optimization-strategies-compute-storage/). It includes cost optimization techniques for cloud storage services such as cleanup multipart load, compress storage, reduce cost on API access etc.*