Six Effective Ways to Reduce Compute Costs
Lets look into the top six ways that can help reducing your compute costs on AWS.
In today’s article, I will cover the common ways to reduce the compute costs. Since I have worked on AWS for the most part, I will talk from the EC2 perspective, however it can be applied to other cloud platforms.
These techniques may look very common sense but overlooked mostly leading to an expensive bill. Let’s revisit and refresh our memory.
Today’s post is brought to you by Schematic.
You don't build auth from scratch. Why build pricing?
Stripe is great —but entitlements, metering, upgrades, and webhooks aren't. Stop wasting time wrestling with billing logic. Schematic is like Auth for pricing & packaging —abstracting the last mile so you can move faster.
See why companies like BlackCloak, Automox, and Zep trust Schematic.
Pick the right Instance Type
Selecting the right instance type for the job is crucial. There are two ways you can find the right type:
Plan ahead and perform back of the envelope estimation. This helps in getting an idea of how much memory, CPU and storage is needed for the usecase.
For non critical jobs, you can start with small instance type and optimize from there until you reach the desired outcome.
Here is a snapshot of AWS instance types for the most popular region, source:
![](https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c79ae17-0ba7-48b7-bfef-18f3ea3f6e59_968x596.png)
Furthermore, AWS Graviton based instances are 20% cheaper, source.
📖If you leverage Spark, then checkout my article from the past: Optimizing Spark Cluster
Leverage Spot Instances
Spot instances are upto 90% cheaper than on demand. However, Spot may not work always especially for critical workloads where availability of the service is important.
Choose Spot instances if your service can tolerate recovery from failures.
Opt for a mix of Spot and On-Demand instances to balance availability and cost.
Use On-Demand instances when strict SLAs must be met.
Effective Auto Scaling
Auto scaling allows you to pay only for what you need. For example, instead of maintaining a consistently high number of nodes, you can set an average capacity with auto scaling, which adjusts resources as needed and helps reduce costs.
Two common approaches to trigger auto scaling:
Based on number of events in the source system e.g. messaging system like Kafka.
Based on resource utilization, e.g. CPU utilization.
Efficient Scheduling
Efficient scheduling means choosing the right time to maximize the value of your instances. If you operate during peak hours:
You may struggle to keep Spot instances.
You may struggle to provision new nodes especially if using popular instance types.
Enable Automatic Shutdown
A simple way to save cost is to make sure we kill the Zombie Resources through automatic shutdown. This feature is available in modern services like Kubernetes or EMR cluster.
Two common options:
Once the job is completed, usually in production environment.
Once the compute has no activity for specified amount of time, usually in analytical workflows.
Go Multi Region
AWS us-east-1 region has huge demand. If you are looking for big number of instances in that region you might not find enough unless you reserve beforehand.
You can consider moving to less popular and cheaper region, make sure to check if your required instance types are supported in that region.
This will not only help you provision cheaper instances easily but also leverage Spot for the most part leading to more cost savings.
Expect potential slowness due to network latency, especially if compute and data are in separate regions. This may also impact data transfer costs.
💡 Regular monitoring is crucial for identifying optimization opportunities.
💡 Switching to serverless services like Lambda or ECS/Fargate can be a great option to explore.
If you are looking for Optimization related to Spark then checkout this series:
Introduction to Spark Optimization
💬 What additional cost optimization techniques would you include in the list?