Bonus content: Guide to Amazon EC2 instance types
AWS doesn’t make a developer’s life easier. How are you supposed to make sense of EC2 pricing when there are so many different EC2 instance types out there?
Picking the right VM type for the job is difficult. But it doesn’t have to be.
Read on for a quick introduction and AWS EC2 pricing and expert tips for slashing your cloud bill.
What are Amazon EC2 instances?
Amazon EC2 stands for Amazon Elastic Compute Cloud, a web service that brings you compute capacity in the cloud. AWS designed these virtual machines to help developers reap the benefits of web-scale cloud computing.
The service offers almost 400 different instances with choices of various processors (Intel, AMD, or Arm-based), storage options, networking, operating systems, and purchase models – all across a total of 24 regions and 77 availability zones located all over the world.
EC2 instance types
This EC2 instance type offers a balanced ratio of CPU to memory. It’s a good fit for general-purpose applications that use CPU and memory in equal proportions – for example, web servers with low to medium traffic or small to medium databases.
This type is optimized for CPU-intensive workloads, so it comes with a high ratio of CPU to memory. Pick it for web servers with medium traffic, batch preprocessing, network appliances, and application servers.
This EC2 instance type has a high memory-to-CPU ratio. It’s a great fit for production workloads – for example, database servers, relational database services, analytics, and larger in-memory caches.
Choose this EC2 instance type for workloads that require heavy read/write operations and low latency. Thanks to high disk throughput and IO, storage optimized instances come in handy for Big Data, SQL and NoSQL databases, data warehousing, and large transactional databases
This instance type uses hardware accelerators (co-processors) to carry out functions like data pattern matching, graphics processing, and floating-point number calculations better than software running on CPUs. A great choice for machine learning (ML) and high-performance computing (HPC).
AWS designed this EC2 instance type to support machine learning applications. AWS EC2 Inf1 promises up to 30% higher throughput and 45% lower cost per inference than AWS EC2 G4 instance. It includes 16 AWS Inferentia chips, 2nd generation Intel® Xeon® Scalable processors, and up to 100 Gbps networking.
Read this to learn more: 400(!) EC2 instance types: the good, the bad, and the ugly
Quick guide to AWS EC2 pricing
The pay-as-you-go model works well for many teams because they only get to pay for resources they actually use. You can increase or reduce your usage just in time without having to worry about any long-term binding contracts or upfront payments. This is how you also avoid the risk of overcommitting to a budget.
How to hack On-Demand instances?
- Don’t forget that this convenient option is also costly, so you’re risking overrunning your budget.
- These flexible instances work well for unpredictable workloads with fluctuating traffic spikes—otherwise, better look into alternatives.
It all looks great in theory. Buy capacity upfront for 1 or 3 years in a given availability zone and get a really good discount compared to On-Demand pricing. And the bigger your upfront payment, the bigger the discount.
How to hack Reserved Instances?
- Better avoid them. What if you commit to resources that don’t make sense for your company in a year?
- You’re committing to a specific instance or family. Changing this later isn’t possible. And what if your requirements change in the meantime? You’re blocked.
Savings Plans work like Reserved Instances, only you’re committing to a specific amount of compute power to be used over 1 or 3 years. All the usage covered by your commitment will be covered, and you’ll pay the On-Demand rate for anything extra.
How to hack Savings Plans?
- Better avoid them.
- You’re not committing to specific instance types and configurations, but you still run the risk of locking yourself in with the cloud vendor.
- Again, you commit to paying for resources that might make zero sense for your company in 1 or 3 years.
This goes for both Reserved Instances and Savings Plans: When your requirements change, you either commit even more or get stuck with unused capacity. These options prevent any flexibility of scaling, seasonality, or ability to configure multi-region/zone distribution easily.
Are you running on AWS Savings Plans? You can still reduce your cloud bill, here’s how
Spot instances offer an amazing opportunity to reduce cloud costs by getting instances at up to 90% off the On-Demand pricing. By bidding on resources AWS isn’t using, you get to save up and expose your workloads to potential interruption. However, this EC2 pricing model comes at a price. AWS can pull the plug at any time and give you a 2-minute warning.
How to hack Spot Instances?
- Pick them for workloads that can tolerate interruptions – for example, stateless application components like microservices or replicable applications.
- Read this guide to reap all the benefits of Spot Instances: Spot instances: How to reduce AWS, Azure, and GCP costs by 90%
This is basically a physical server that offers instance capacity exclusively to you. You get the resiliency and flexibility of AWS and the cost benefits of using your own licenses.
How to hack Dedicated Hosts?
- This is a good choice for companies looking to achieve compliance or avoid sharing hardware with other tenants for security reasons.
- You’re billed hourly for every active Dedicated Host, not running instance.
- It’s an expensive option.
Whichever EC2 pricing model you choose, don’t forget about these extra charges
AWS charges for extra things like egress traffic, load balancing, block storage, IP addresses, and premium support. Consider these costs when comparing different pricing models and building your cloud budget.
5 tips for achieving the right Amazon EC2 pricing and performance combo
1. Define your requirements
See an affordable instance? You might be tempted to get it. But what if it can’t handle your workload once you run a memory-intensive application? Prepare for poor performance that might affect the reputation of your entire company.
That’s why you need to start by clarifying your requirements. Compute costs are the biggest item on your cloud bill, so make a deliberate effort to order only what you actually need.
Consider your requirements across all compute dimensions:
- CPU Count
- CPU Architecture
- SSD Storage
Let’s say that you’ve done your research, know your exact requirements, and found a targeted set of instance types that match them. Choosing the first “good enough” instance might backfire on you. EC2 instances come with various price vs. performance ratios. You might be able to secure better performance for the cloud compute dollar and slash your costs.
Next comes the question: Should you go for a CPU vs. GPU dense instance?
If you’re building an application based on machine learning, go for GPU. They’re much faster when it comes to training models.
And consider a specialized instance type like AWS EC2 Inf1 that is supposed to work really well for running predictions through your trained models.
Otherwise, a CPU-based instance will do the job.
2. Pick the right instance type, here’s how
AWS offers several instance types optimized for different use cases; just take a look at the table above.
For each type, you can choose from one or more instance sizes. This allows scaling the resources to match your workload’s requirements.
But cloud service providers roll out different computers for these instances. And the chips in those computers have different performance characteristics.
You might end up with an older-generation processor that is slightly slower or a faster, new-generation one. So, the instance you pick might have strong performance characteristics that you don’t even need. And you don’t even know about it!
Solution? You can verify this via benchmarking. Just drop the same workload on each machine type and check its performance.
We did this at CAST AI when we started over a year ago. Here’s what we learned:
Benchmarking case study: Unpredictable CPU behavior
The chart below shows CPU operation in Amazon t2-2x large (8 virtual cores) at different times after several idle CPU periods.
Source: CAST AI
A note about processors: ARM-powered instances
AWS offers ARM-powered VMs like the AWS EC2 A1 family that uses a Graviton2 ARM processor. ARM is an interesting choice: it consumes less power, so running and cooling it is cheaper. That’s why cloud providers tend to charge less for this type of processor.
But if you’d like to use it, you might have to re-architect your delivery pipeline and compile your application for ARM. Unless you’re already running an interpreted stack like Python, Ruby, or NodeJS – then your applications are likely to run.
3. Take advantage of CPU bursting
Burstable performance instances were designed to offer a baseline level of CPU performance with the opportunity to burst to a higher level exactly when your workload needs it.
Burstable performance instances are a good choice for low-latency interactive applications, microservices, small and medium databases, and product prototypes.
The number of accumulated CPU credits depends on the instance type. Larger instances collect more credits per hour. But they also come with a higher cutoff to the number of credits you can collect.
Here are a few facts about burstable performance instances in AWS:
- They’re available in instance families: T2, T3, T3a, and T4g.
- Restarting an instance in the T2 family leads to losing all the accrued credits.
- Restarting an instance in the T3 and T4 families means that your credits will persevere for seven days and then will be lost.
Our research into AWS burstable performance instances showed that if you load your instance for 4 hours or more each day on average, a non-burstable instance is a better choice. But if you run an e-commerce site that gets a large stream of visitors once in a while, it’s a good fit.
Also, CPU capacity tends to increase linearly during the first 4 hours. After that, it becomes much more limited, as in this example of T2.2Xlarge:
Source: CAST AI
4. Check storage transfer limitations
To cut costs on EC2 pricing, you need to consider data storage as well.
AWS EC2 instances use Elastic Block Store (EBS) to store disk volumes. You can also get local ephemeral storage in AWS.
Each application comes with its unique storage needs. When picking an instance, ensure that it has a suitable storage throughput.
Avoid pricey drive options like premium SSD unless you expect to use them to the fullest.
5. Take advantage of spot instances
Spot Instances are a great way to save up on your AWS bill. By bidding on instances AWS isn’t using, you can get up to a 90% discount on the On-Demand pricing.
To get started, make sure that your workload is a good candidate for Spot Instances by asking these questions:
- How much time does it need to finish the job?
- Is it a mission- and time-critical workload?
- Can it tolerate interruptions well?
- Is it tightly coupled between instance nodes?
- What’s your strategy for moving your workload when AWS pulls the plug?
When picking a Spot Instance, consider the less popular ones – the chances of getting interrupted are lower.
You can also check an instance’s frequency of interruption. This is the rate at which the instance reclaimed capacity during the trailing month. Take a look at the AWS Spot Instance Advisor:
Don’t be afraid of using Spot Instances for more important workloads. AWS offers an instance type that guarantees uninterrupted operation for up to 6 hours (in hourly increments). You have to pay a little more for it, but you’ll still get a 30-50% discount.
When bidding your price, set one equal to the On-Demand pricing. Otherwise, the risk of your workload getting interrupted is higher once the price goes up.
Increase your chances of getting Spot Instances by setting up groups called AWS Spot Fleets. They allow you to request multiple instance types at the same time. And you’ll pay the maximum price per hour for the entire fleet, not a specific spot pool (instances with the same type, OS, availability zone, and network).
How to apply all of this?
Choosing the right instances and fixing EC2 pricing manually is a challenging task. But you can delegate this important job to an instance selection algorithm like the one we built at CAST AI.
An algorithm like that can choose the best instance type to meet the application requirements whenever a cluster needs extra nodes. This means that your workloads will be running at maximum performance and minimum cost.
Here’s how it works:
- At 15:41, the application receives a surge of unexpected traffic. The Horizontal Pod Autoscaler creates new pods, but they have no place to run. So, we get an instant requirement for 15.5 new CPU cores.
- Within 2 minutes, CAST AI adds a new 16-core node automatically.
- At 15:45, additional traffic appears in the application.
- To manage this, it adds an extra 8-core node within one minute.
- Once the traffic is gone, CAST AI instantly retires 2 nodes to avoid resource waste.
Note that the cost optimization engine selected Spot Instances for the extra work available at a large discount.
If you use the Amazon EC2 instances to run Kubernetes clusters, you can start your journey with automation now. Run a free Savings report to see how much you can save on your EC2 charges.
An Amazon EC2 instance is a virtual machine located in Amazon’s Elastic Compute Cloud (EC2) that allows teams to run applications on the Amazon Web Services (AWS) infrastructure.
This scalable service is designed for flexibility and convenience, as it comes with a user-friendly interface that gives complete control over cloud resources.
An Amazon EC2 instance can act as a virtual server hosted in the AWS cloud. There are many types of Amazon EC2 instances available, each ideal for different needs, using various operating systems (OS), applications, and other customizable features.
Amazon EC2 offers a variety of instance types, each tailored to a particular type of workload. Naturally, each type comes at a different EC2 pricing level. Instance types include combinations of CPU, memory, storage, and networking capacity, allowing you to choose the mix that is most appropriate for your application.
The instance size determines the memory and CPU resources available on an instance, enabling you to scale your resource allocation as needed.
For example, general-purpose instances provide a good balance of CPU, memory, and networking resources for a range of diverse workloads, making them suitable for a variety of applications such as web servers and code repositories.
Compute-optimized instances are highly performant instances designed for compute-intensive applications that use large amounts of processor power. And memory optimized instances are designed to process large amounts of data in memory, making them ideal for applications that need to run high volumes of concurrent requests or queries. These are just three examples of EC2 instance types.
AWS currently offers almost 400 different instances with choices across storage options, networking, operating systems.
Users can choose from five pricing models for Amazon EC2 instances: On-Demand Instances, Reserved Instances, Savings Plans, Spot Instances, and Dedicated Hosts.
EC2 pricing tiers and models significantly impact billing charges, as well as optimization features like Amazon EC2 Auto Scaling and AWS Compute Optimizer.
EC2 pricing refers to different models AWS uses to bill its EC2 services. Currently, AWS users can choose from five different models:
– On-Demand – this is the most expensive and flexible option based on pay-as-you-go, meaning that you pay for the exact resources you use.
– Reserved Instances and Savings Plans – these two options offer great discounts based on upfront payments for specific resources or usage levels. These two EC2 pricing models are popular among companies that use massive volumes of cloud resources, but they come with a 1- or 3-year commitment.
– Spot instances – this model offers incredible discounts on cloud resources that any AWS customers aren’t using. Still, once a customer buys the capacity, AWS pulls the plug on the spot instance. Teams looking to benefit from spot need to have a mechanism to handle this interruption. This is where automation can help a lot.
– Dedicated Hosts – this is an optimal solution for businesses in highly-regulated industries that want to benefit from the cloud but cannot share resources with other organizations.
AWS launched a new Amazon EC2 Spot model at re:Invent 2017 to allow customers to reserve instances at a discount. The new model provides predictable prices that adjust slowly over days and weeks, with typical savings of 70-90% over On-Demand.
The previous pricing model that gave users free reign in the marketplace, made it hard to estimate the bidding strategy and the price for spot instances.
Now you pay a spot cost that’s in effect for the current hour for the instances that you launch. You can also focus on running your business without having to spend time analyzing market prices or setting maximum bid prices.
Spot instances receive a two-minute interruption notice when they’re about to be reclaimed by EC2. AWS has also reduced interruption times with this new EC2 Spot model.