How to Optimize Your AWS Spend
What happens if you give your teenager your credit card and just let them rip? It’s (very) possible that your money will be pretty garishly misspent.
Similarly, while the cloud can be a massive driver of efficiency and cost savings, if you're not using it correctly the sky’s practically the limit on how much you can waste.
We’ve seen clients who have migrated to AWS but not seen the benefits because they were still treating it like on-premises and not doing some simple things to optimize their cost strategy. In this blog, I’ll talk through some simple things to watch for to squeeze all the juice out of your cloud programme.
Firstly, considering the 80-20 rule, you’re likely to reap huge benefits by focusing your cost reduction efforts on your top expenses. AWS would be the first place to reduce costs without damaging your user experience, or reputation as an organization.
AWS has numerous services, and their pricing model for each service is very intricate. You need to know where to start, and how to go about achieving cost reduction with AWS. Coming back to the 80-20 rule, you should look at which AWS services account for most of your spend. For most organizations, this would be EC2 instances. That’s our focus for this post.
Right-size Your EC2 Instances
There are hundreds of instance types to choose from within AWS, and it’s tempting to choose the most powerful instances, especially when coming from an on-premises data centre where server costs are unreasonably higher than AWS’ powerful cloud instances. Still, the right thing to do is to start small, and scale fast based on need. AWS itself are big proponents of right- sizing—choosing the smallest possible instance without compromising performance.
You can use AWS’ total cost of ownership (TCO) calculator to make sure you select the right instance types for your need. We have a blog and demo video of how to use the TCO calculator here, with more information on that topic.
Lock-in Reserved Instances
After choosing the right instance type, the next big win is in the pricing model. AWS has designed their pricing so that you pay more for on-demand instances, and much less for instances that you ‘block’ or ‘commit to’ for the long term. These long-term instances are called Reserved Instances, and you can reserve them for up to three years. There are two types of Reserved Instances: Standard and Convertible. Standard Reserved Instances give you access to only the type of instance you commit to, whereas Convertible Reserved Instances let you switch between instance types at any time. Standard instances come with an approximately 75% discount, and convertible instances will give you an around 54% discount over on-demand instances.
Bet on Spot Instances
Another way to pay for your instances is with Spot Instances. These are unused AWS instances that go on auction in a marketplace. If your bid matches the market value for an instance, it becomes yours. However, as a word of caution, Spot Instances can be reclaimed (with a two-minute notification) if their market price goes up. Despite this, Spot Instances are a great way to save up to 90% on on-demand instances, and are particularly well-suited for dynamic and non-critical workloads like data processing. TapSense, an advertising company, saved $50k annually with Spot Instances.
Shift workloads from EC2 to Lambda
EC2 instances can leave a lot of wastage when you consider that their utilization is about 60-80% at most times.
Source: Prerender.cloud
Prerender did a comparison between EC2 and Lambda, and found that for workloads that require quick burst, but not necessarily low latency or high memory, Lambda does the job better and costs about 30% of an EC2 T2.nano instance. However, for workloads that can’t tolerate cold starts, EC2 is still the better bet as it is always on, unlike a Lambda function where new resources are provisioned every time functions are executed. Of course, this provisioning is automatic, but there is a lag that can be intolerable for applications that need to be responsive and quick from the get-go. This cold start issue led Viacom to rule out Lambda for their applications that are user-facing.
In a recent blog post, Stuart Slade, a security expert at Contino, shared an example of moving an existing system from on-prem to a cloud instance, and paying just 1% of their previous spend. Further, they moved this system from a cloud instance to Lambda, and reduced costs to a mere 0.01% of the original on-prem infrastructure.
So, your mileage may vary with Lambda, but depending on your workload, you could potentially save a lot by running some workloads on Lambda over EC2 (not to mention the hassle-free experience of running functions on Lambda and not having to maintain any cloud instances). This makes Lambda seem like a great alternative, or complementary option, to EC2.
Shift workloads from EC2 to ECS
Similarly, you can use ECS, Amazon’s container service, to run workloads on a Spot Fleet of instances. Like Lambda, ECS is a great platform to run dynamic workloads, and is a great option when you want to keep your EC2 instances for steady workloads, and run dynamic ones on more flexible and economic infrastructure. You can automate the entire process by using CloudWatch Alarms to send out a trigger whenever your EC2 cluster reaches 75% or 80% of its utilization.
As you can tell, EC2 is the centrepiece of the AWS cloud, but it can drain your spend easily if you’re unaware of all the options available to you. By understanding the various instance types, pricing models, and complementary AWS services, you can greatly reduce your overall AWS spend.