December 01, 2017 / by Reflexica AWS, Cost Optimisation

A Handy Guide To AWS EC2 Cost Optimisation

EC2 cost optimisation can improve the profitability of your organization. Here are some of the most easily implementable strategies you can use to achieve this.

Reserved Instances

While Amazon Web Services (AWS) On-Demand hourly rates may offer significant cost savings for unpredictable workloads, they may not make financial sense for more predictable workload application requirements. If your workload is predictable, you should use AWS Elastic Compute Cloud (EC2) Reserved Instances. Compared to Amazon’s EC2 on-demand hourly rates, the AWS Reserved Instances are up to 75% more cost effective when applied to predictable workloads. The pricing of Reserved Instances is based on the following three variables:

• Instance attributes these attributes include instance platform, availability, type and zone. For instance, if you purchase a Reserved Instance m4.2xlarge Linux/UNIX RI with default tenancy in US East, you would automatically receive a discounted Reserved Instance rate every time you run an instance with these attributes.

• Term commitment AWS offers Reserved Instances (RIs) for either one- or three-year term, with the latter offering a larger discount.

• Payment options On the payment front, AWS offers three payment options including No Upfront, Partial Upfront and All Upfront. The All Upfront payment option allows for greater savings, whereas the No Upfront or Partial payment options would require you to pay your balance in monthly increments over the duration of your contract.

It is important to note that, if your application workload requirements change or go away before the end of your term, Reserved Instances would allow you to modify the availability zone within the region where your RI is located, the networking type. Moreover, if you are using a Linux Reserved Instance, you can modify the instance type to another size in the same family at no extra cost. Alternatively, if you no longer need your Reserved Instance, you can sell it on the Reserved Instance Marketplace as a third-party seller. Overall, irrespective of your workload application requirements, the AWS EC2 Reserved Instances can help you save up to 75% on your Amazon EC2 bill while ensuring you have the computing capacity to meet your application workload requirements.

EC2 Spot Instances

Spot Instances are essentially AWS EC2 Instances (servers) that you can add bid on. Simply put, with Amazon’s Spot Instances, you determine the price that you are willing to pay for capacity at any given time. Spot Instances are particularly ideal for workloads that are tolerant to interruptions and time flexible. Prices for Spot Instances are often significantly lower than prices for EC2 On-Demand Instances, meaning you are more likely to save costs with Spot Instances. However, the price of Spot Instances typically changes constantly based on the market forces of supply and demand.

When you place your bid and it exceeds the prevailing Spot price, Amazon’s EC2 platform will launch your Spot Instances, and they will run until the Spot price equals or exceeds your bid, or until you terminate the Spot Instances. To use Spot Instances, you have to place a Spot Instances request that specifies the number of instances you require, the types of instances you want and more importantly, the amount of money you are willing to pay for every Instance hour. To help you with your bid, you can get the history for Spot pricing for the past three months via either the Amazon EC2 API or the AWS management console. The AWS Spot Instances essentially offer a cost-effective way to add computing resources to a workload, accelerate batch workloads or add resources to non-critical workloads. This means they are particularly useful in batch production workloads including analytics, big data, financial modeling, computational science, testing and coding. AWS Spot Instances enable such workloads to add capacity easily at a relatively low price.

It is important to note that, while Spot Instances typically perform like other Amazon EC2 Instances when they are running, their pricing model is different and they can be interrupted under certain conditions. For instance, when the Spot price exceeds or equals your maximum bid price, your Spot Instances will be terminated, meaning you will never pay more than your maximum hourly bid price. Additionally, it is worth noting that Amazon only charges for a full hour of usage. This means that, in case Amazon interrupts your Spot Instances, you will not pay for the partial hour of usage. Furthermore, bidding higher cannot prevent the potential for interruptions, meaning you should only use Spot Instances for workloads that can handle interruptions. That said, Spot Instances integrate seamlessly with other AWS services including Amazon Virtual Private Cloud (VPC), Auto Scaling and Amazon Elastic Compute Cloud (EC2). This makes it easier for you to incorporate other cost cutting AWS Instances into your existing architectures, as well as save money with other third-party services, too.

For short-term usage, the cost of Spot Instances can be up to 90% lower than the cost of On-Demand Instances.

EC2 Spot Fleets

An Amazon Spot Fleet is basically a collection of Spot Instances. In other words, a Spot Fleet is a pool of unutilised EC2 instances with the same network platform (EC2-VPC or EC2-Classic), Availability Zone, operating system and instance type. This pool of Spot Instances is important because it strives to do two things. Firstly, it strives to maintain the specified capacity fleet in the event your Spot Instances are terminated due to a change in either the available capacity or Spot price. Secondly, it attempts to launch the amount of Spot Instances necessarily to meet the target capacity specified in the Spot Fleet request.

It is worth noting that the Spot Fleet selects Spot Instance pools based on the launch specifications contained in the Spot Fleet request. Such specifications include the Availability Zone, subnet, AMI and instance type. Moreover, you can include multiple launch specifications in your Spot Fleet request, as well as specify your allocation strategy (lowest price or diversified). The lowest price strategy is the default strategy and it essentially picks Spot Instances from the Spot Instances pool with the lowest price. The diversified strategy, on the other hand, distributes Spot Instances across all pools.

Each Spot Fleet request can include either the default On-Demand price or a global maximum price. For each of its launch specification, the Spot Fleet uses the default maximum price stated in the Spot Fleet request. However, you can optionally specify a maximum price for a particular launch specification or multiple launch specifications, effectively overriding the global maximum price. Put another way, the Spot Fleet will use this maximum price instead of the global maximum price for the specified launch.

Right Sizing EC2 Instances

AWS offers more than 60 instance types. However, the right instance is not necessary the biggest and most powerful. For this reason, you should choose the most cost efficient instance for your needs. This is where rightsizing comes in handy. Rightsizing is basically the process of choosing the cheapest instance that would be able to meet your application workload requirements. The process may entail monitoring and auditing your existing architecture to identify opportunities to down size without compromising capacity. AWS customers can use their Amazon EC2 Usage Reports to determine whether they should implement cost optimisation strategies or not. In essence, rightsizing can help you save money without compromising your application workload requirements. Some of the things you can do to boost your cost optimisation efforts include:

Turn Off Unused Instances

This is one that is often overlooked, but by shutting down instances that are not in use, you could dramatically reduce your operational costs, especially when working with multiple applications with multiple environments (Dev, Staging, QA, Production, etc). You can use tools such as EC2 Scheduler to automate the start and stop actions and therefore maximize your savings. Another clever solution we’ve heard of is the use of IoT buttons, where the last developer out of office at the end day can turn off staging instances, simply by tapping the a button next to the door. The first developer back in the day after can then use the button to restart the instances.

Auto-scaling EC2 Instances

The AWS Auto Scaling feature makes sure you have the correct number of Amazon EC2 servers (instances) to handle the load of your application. To achieve this goal, Auto Scaling dynamically regulates your computing capacity requirements based on changes in a user’s metrics or schedule. Simply put, Auto Scaling will increase your number of instances during higher workloads and decrease the number of instances during lower workloads. By doing this, it will help optimise costs. For the best results, always ensure you scale at the right level of granularity in order to enjoy the cost-saving benefits of the feature. This means you should not have excessive amounts of granularity that have excessive amounts of capacity provisioned for long periods. Fortunately, AWS offers a low cost solution to experiment and try different scaling models and sizes. This allows users to scale in a responsive manner and optimize their costs at the same time.

Monitor your costs on a daily basis

This one goes for all AWS services, not just EC2. With regular monitoring and having the correct tools in place, you can catch issues early and avoid facing a hefty bill. Use AWS cost and reporting tools, detailed billing reports and Cost Explorer to monitor and manage your costs.

Conclusion

Use the EC2 cost optimisation strategies to cut your cloud computing costs. If want to cut your cloud computing costs further, contact us today to arrange a consultation.

Our recent posts

7 DevOps Tools We Love - And 1 We Love To Hate

December 10, 2017

7 DevOps Tools We Love - And 1 We Love To Hate

For many DevOps engineers, the workday is often spent using a variety of tools to be more productive and increase efficiency, and due to the often intensive work it's important to use tools they can rely on.

A Handy Guide To AWS EC2 Cost Optimisation

December 01, 2017

A Handy Guide To AWS EC2 Cost Optimisation

EC2 cost optimisation can improve the profitability of your organization. We give you some helpful tips on how to reduce the costs of your EC2 infrastructure.

Avoiding common AWS migration pitfalls

January 11, 2017

Avoiding common AWS migration pitfalls

The process of moving to the AWS Cloud is not without its pitfalls – here's how to avoid them