Three Ways to Purchase Your AWS EC2 Instance
and How to Run Amazon EC2 Workloads at Scale
What are Amazon Web Services (AWS) EC2 Instances?
According to AWS, Amazon Elastic Compute Cloud (EC2) is “a web service that provides secure, resizable compute capacity in the cloud.” Its web-based interface lets you purchase and control your computing resources on Amazon’s computing environment.
What EC2 Instance Types are available?
The power of the cloud is that it is highly customizable. Amazon instance types are made up of different combinations of memory, networking capacity, storage, and CPU. Learn more about which instance types may be right for you.
How can I purchase AWS EC2 Instances?
AWS provides four main EC2 instance purchasing options. They are: On-Demand, Reserved Instances, and Spot Instances, with the added option of Dedicated Hosts.
How to Optimize Your Cloud Spend With AWS EC2 Instances
As many companies have found out the hard way, running large, heavily-trafficked applications in the cloud can become expensive. New cloud users may think this eats away at the cost savings from getting rid of the on-premise data center altogether.
The good news is that it’s possible to cut cloud costs without compromising on performance. However, optimizing cloud spend requires understanding the different purchase models and instance types available from each cloud provider, as well as finding the right balance between high availability and cost concerns. This overview will summarize your options for provisioning AWS cloud services.
EC2 instances launched in 2007 with one instance type. Since then, AWS has been adding new instance types, and there are now over 70. These instance types not only vary by size—some are optimized for compute, some are optimized for memory and others are ‘generalist’ instances. Part of running workloads at scale involves ensuring that you’re choosing the right type of instance, not just the proper instance size, for your application.
Regardless of what type of instance you’re using, you’ll have the same purchase options.
This is the most basic, least sophisticated way to provision Amazon EC2 instances. It’s the pay-as-you-go model. On-demand EC2 instance purchasing is also the most expensive way to provision resources. If you’re running an EC2 workload at scale, managing all of your instance provisioning on an on-demand basis would get quite expensive.
Reserved Instance (RI) purchases are one of the easiest ways to start reducing cloud spends. When you buy an RI, you are ‘reserving’ that instance for a one to three year period. In return for that long-term commitment, AWS gives a hefty discount of up to 70% off compared to the on-demand prices. Professional service providers may find RI purchasing to be the most economical option for increasing profits while adding value for their customers.
Spot Instances allow you to take advantage of Amazon’s ‘extra’ capacity. Spot instances are offered at a deep discount of up to 90% off the on-demand prices. The catch is that you don’t actually reserve them. If someone else requests to use those instances, you’ll be disconnected after a two-minute warning.
Obviously, Spot Instances are not great for customer-facing, time-sensitive use cases, or for applications that can’t be interrupted—like a company website. However, most businesses have some workloads that can be interrupted and are not time-sensitive. If you’re running any workloads that fit those requirements, Spot Instances are an option for reducing costs substantially.
Finding the Best Fit
Running AWS workloads at scale without running up huge bills involves ensuring that you’re not paying for more capacity than you actually need. There are two primary strategies for doing so: right sizing and autoscaling.
Right sizing means provisioning the cloud resources to appropriately match your usage. This sounds much simpler than it is in practice because AWS does not provide native tooling that would make it possible to access granular enough usage data for businesses to understand their ideal instance size, instance type, and the number of instances.
Understanding which instance type to use for certain applications requires an understanding of how much compute and memory that specific application is using. Once you have that information, you can provision the optimal instance type and number of instances for your particular workload.
Right sizing also allows companies to get the most out of RI purchases. Once you determine the ideal configuration for your instances, you can purchase Reserved Instances to reduce costs further.
The disadvantage of relying on right-sizing as a cost management strategy is that it works best for workloads with relatively stable traffic. If you’re handling a workload with wildly varying needs, right sizing is difficult and RI purchases invariably lead to underutilization as well as the risk of failure if your traffic spikes over the amount you’ve reserved.
Autoscaling is another strategy to ensure your cloud resource provisioning matches your actual usage as closely as possible. Contrary to some expectations, AWS Auto Scaling is not an out-of-the-box feature. It’s something you have to actively manage and configure. In doing so, you can configure the rules to autoscale to specific types of instances and combine on-demand instances and spot instances.
Autoscaling doesn’t offer the cost advantages of Reserved Instances but is a better way to manage fluctuating workloads.
Right sizing and autoscaling are not an either/or proposition. Managing EC2 workloads at scale will likely involve a mixture of both strategies. This would involve identifying your ‘baseline’ workload—or the minimum amount of resources the organization will need to have working 24 hours a day. Those resources should be provisioned using RI purchases and right sizing. Anything on top of that can be managed using autoscaling groups that specify which types of instances to add, under specific scenarios.
Related Article: Cloud vs Data Center: What is Scalability in Cloud Computing?
Starting in the fall of 2018, it became possible to combine Reserved Instances, Spot Instances, and On-Demand Instances in a single autoscaling group that is distributed over several availability zones. This makes it possible to get the lowest cost by allowing you to determine, in advance, what percentage of scaling needs should be met with On-Demand and Spot Instances. You can also provide a prioritized list of what AWS EC2 instance types should scale to when adding On-Demand instances so that you can optimize performance even during traffic spikes.
Part of this is done using the AWS EC2 Fleet tool, which makes it possible to integrate allocation strategies into your autoscaling systems, as well as to manage all of your capacity (RIs, On-Demand, and Spot) holistically.
Regardless of how you’re planning your EC2, ensuring that you don’t have outages when EC2 instances fail—something that inevitably happens—usually means deploying to multiple availability zones within an AWS region. This allows your application to automatically failover to the second availability zone if there is any problem with the primary zone, without having traffic routed through a data center in a far-flung region, which could lead to lag time. Failover to the secondary Availability Zone can happen as a result of a failure in the first zone, or it can be part of the scaling strategy to accommodate spikes in traffic. You can see all of the AWS regions and their related Availability Zones here, and also use this tool to compare all of the major cloud providers’ regions and zones.
Autoscaling groups function across Availability Zones within the same region, giving you automatic control over scaling and the ability to ensure high availability while still using cost optimization strategies that look at the entire deployment.
Relying exclusively on On-Demand Instances for EC2 workloads at scale rarely makes sense. AWS has several ways for businesses to optimize cloud costs and ensure they are provisioning the best types of resources for their workloads. Doing so, however, often requires access to analytics that are difficult to impossible to get from AWS’s native tooling.
CloudCheckr can help you understand the best instance types for your workload, help you make better decisions about RI purchases, and help you develop a cost-optimization strategy without compromising the need for high availability.