Cost Optimisation spotlight: Elastic Compute Cloud(EC2)
In this previous post, we covered Cost optimisation at a high level, but now we’ll do a look into EC2 instances, and the ways you can optimise their costs without refactoring.
With any cost optimisation discussion, a big exclaimer that needs to be taken into account is that cost optimisation isn’t always about bringing bills down. It’s about allocating the right budget to get optimal performance, while also removing waste.
The Right Instance for the Job
AWS provides Compute Optimizer, which will compare usage metrics to the performance of the instances, and provide recommendations on whether you’re paying for performance you’re not using (Overprovisioned), or not paying for enough performance (Underprovisioned).
One thing to be aware of is by default, AWS doesn’t collect memory metrics, only CPU. You’ll need to install the AWS CloudWatch Agent and configure it to retrieve memory usage.
Once you do, Compute Optimizer will use the last 14 days usage to determine its recommendations.
Turn it off if you’re not using it
For non-production environments, why run (and pay!) for infrastructure when your team is sleeping? Setting up power scheduling functionality is quite a low bar to set up the AWS Instance Scheduler found here. Set them to power off after hours, and they can be set to power back on in the morning before your team starts for the day. If you’re only working 9-5, that’s a 60% saving being powered off from 5-9. Usually, we see clients have non-prod running from 7-7 to account for early risers and late finishers. Still equates to a 50% savings.
Do note that power scheduling can make reserved instances or savings plans redundant, as those pre-paid contracts are billed as if the infrastructure is on all of the time.
Pre-payment for Compute
AWS offers plenty of options to pre-pay for your EC2 instances and gives some quite sizable discounts depending on the contract terms you agree to.
RI’s let you commit to a 1 or 3-year term, with the choice to pay nothing, 50% or all of the contract cost upfront. You’ll receive a larger discount the longer you commit, and the more you pay upfront. The discount can be up to 72% vs On-Demand pricing. Note that these are agreed to on a per-instance basis.
If you’re not sure whether you may need to increase the instance size, you can agree to a Convertible RI, that will allow you to increase the size of the instance.
If you have a workload that is only powered on for a certain period of a day, week or month, you can also get a Scheduled RI to reserve capacity when you need it, and not pay for it when you don’t, on a regular schedule.
Savings plans come in two flavours, the EC2 Instance Savings plans, and the Compute Savings plans. The EC2 Instance Savings plans will save up to 72% and cover the usage of a particular instance family(of any size) in a region (e.g. T3 in ap-southeast-2).
If you’re unsure what instance family you will require, (and it covers ECS Fargate and Lambda too!) you can use a Compute Savings Plan. This will cover the EC2 compute regardless of family, size or region! It just focuses on how much minimum per hour spend you are committing to.
When providing a recommendation to a client, I usually recommend savings plans, especially compute savings plans. While it’s a slightly lesser saving (up to 66% vs up to 72%), it’s much more flexible. Reserved instances are rather restrictive in comparison to Savings plans, and if your usage grows, then it’s easy enough to apply another Savings plan to obtain the discount on the new On Demand charges. Savings plans and Reserved Instances discounts are not cumulative. Savings Plans are applied first, and anything remaining On Demand has Reserved Instance discounts applied if there are any.
These cost savings methods shine when used in a multi-account Organisation, as then you can apply the savings to any applicable resources to accounts underneath the Organization master. Just be sure to purchase the Savings Plan or Reserved Instance on the Organization Master account.
Overall AWS has provided many different options that allow you to choose your commitment vs the flexibility you’d like. These are achievable without having to refactor anything and are good for getting the costs down while working at longer-term goals such as refactoring to reduce costs further.
If you’re an organisation struggling to keep costs down, reach out here. In addition to our Managed Services practice where we work with clients to manage costs, we also have our DevOps as a Service & App Modernisation teams who can work to remediate and refactor your environments, so you can concentrate on what makes you unique.