AWS offers nearly fifty different types of EC2 instances. It also provides a number of different categories of images, each tailored for different use cases.
Choice is a good thing, and having so many EC2 instance types and categories is a benefit to users. But with so many possibilities, deciding which EC2 instance is the best fit for your needs can be a challenge.
If you’re struggling to decide which EC2 instance to use, this article is for you. It outlines the major EC2 instance types and categories and makes recommendations about which instances are the best fit for certain types of situations.
We won’t discuss every individual instance type. That would be unfeasible, because Amazon currently offers forty-nine distinct EC2 instances. But we’ll cover the most important ones, and discuss the differences between the major categories of EC2 instances.
However, if you are familiar with EC2 instance types, you might be interested in the EC2 backup. Check out our article on how to back up Amazon EC2 instance.
EC2 General-Purpose Instances
AWS breaks its EC2 instance offerings into several high-level categories. The first of these are general-purpose instances.
As the term implies, these instances are designed for standard hosting scenarios. Each instance type in this category provides a balanced assortment of compute, memory and networking resources.
Applications that consume these resources in equal proportions, such as Web servers and code repositories, are well suited for general-purpose EC2 instances.
When it comes to deciding which specific instance type to use within this category, probably the most important factor to consider is whether the application you wish to run will benefit from EC2’s burstable performance feature. Instances that support burstable performance can access extra compute resources on demand.
This is a useful feature for applications whose demand is typically stable, but which experience occasional spikes in activity. A Web server that hosts an online shopping site is a good example. Such an application is likely to experience a relatively consistent load most of the time, but may see spikes in demand when an item goes on sale or during peak shopping hours. Burstable performance helps to ensure that your EC2 instance can meet the extra demand without slowing down. This feature is available for instances in the T2 subcategory of EC2’s general-purpose instance types.
EC2 Compute-Optimized Instances
If your application consumes a lot of computing resources but does not require a great deal of memory or storage space, EC2’s compute-optimized category is a good solution.
Compute-optimized instances deliver access to a large number of virtual CPUs (but not dedicated physical CPUs), with comparatively less storage and networking.
This category of EC2 instance is a good foundation for hosting data analytics workloads (in cases where the data itself is stored elsewhere) and video processing, for example.
If you need I/O speeds that can keep pace with your virtual CPUs, you may want to use a C3 instance within the compute-optimized category. C3 instances feature solid-state storage, which enables faster data read and write speeds than standard storage. Solid-state storage can help to ensure that data I/O does not undercut your ability to take advantage of high compute power.
EC2 Memory-Optimized Instances
In cases where access to volatile memory -- i.e., RAM -- is the most important consideration, EC2’s memory-optimized instances are the best choice.
The most obvious use case for memory-optimized instances is applications that are designed to take full advantage of the extremely high I/O rates of RAM, such as Apache Spark. In other situations, you may wish to host a database in memory; SQLite, Microsoft SQL Server and a variety of other databases can support in-memory storage.
Most memory-optimized EC2 instances also provide some solid-state storage. This is useful because data stored in memory will disappear in the event that your EC2 instance shuts down and you have not copied the data to a persistent storage location. You can use the solid-state storage to back up your data persistently.
However, some instances in this category of EC2 instance types -- particularly those that offer the greatest amount of memory -- do not provide any persistent storage. The latter instance types are an ideal choice in cases where you simply want as much memory as possible at the lowest price point and do not require solid-state storage or will back up your data to a storage location external to the EC2 instance.
EC2 Accelerated-Computing Instances
You may not think of the cloud as a place for GPU-accelerated computing. Most cloud servers provide little or no access to dedicated video devices.
EC2’s accelerated-computing instances are an exception. They offer access to high-performance GPUs for video-accelerated applications, such as video rendering or certain big data analytics workloads designed to use GPUs for compute operations.
The accelerated-computing category is broken into subcategories of instances. Each subcategory is designed for a different class of use cases, ranging from GPU compute workloads to graphics workloads.
EC2 Storage-Optimized Instances
In most cases, you would use S3 as your data storage solution on AWS and connect EC2 instances to S3 buckets as needed.
However, AWS also offers EC2 instances that are optimized for large amounts of local storage within the EC2 instance itself. These storage-optimized instances are useful for situations where connecting to S3 storage would be difficult because of performance issues, permissions challenges or other limitations associated with S3 (which is not designed for high-performance storage and does not offer solid-state drives).
The storage-optimized instances include solid-state options as well as conventional storage. Both types of storage within this category of EC2 instances are designed to deliver high I/O, however.
AWS EC2 Instance Types Comparison
|Example applications||Web server, code repository||Data analytics, video processing||In-memory databases, Apache Spark||Video rendering, GPU-assisted machine learning||Distributed databases, data analytics|
|Special features||Burstable performance (some instances)||SSD storage (some instances)||SSD storage (most instances; some instances have no persistent storage)||Special GPUs (different types available for different instances and use cases)||High-throughput disks (SSD as well as conventional options)|
If you’re seeking to optimize your EC2 costs, you should understand that what you pay for EC2 instances depends on which type of EC2 pricing model you use. There are four types:
- On-demand, which provides instant access to as much compute, memory and storage as you need. However, on-demand pricing is generally the most expensive.
- Spot instances. With spot instances, you can bid for EC2 resources that otherwise go unused. Spot instances are kind of like eBay for EC2. They can save you a lot of money, but you have to work with whatever is available in the spot category at a given moment. You don’t get to access resources on demand.
- Reserved instances, which give you access to a dedicated but finite amount of resources. Reserved instances don’t provide the scalability of on-demand pricing, but they are less expensive. They work well in cases where the demand on your application is consistent and predictable, and will not exceed the amount of capacity you reserve through a reserved instance.
- Dedicated hosts. With a dedicated host, you get exclusive access to a physical server in the AWS cloud. Dedicated host pricing is generally expensive, but if used in the right way, a dedicated host can save you money. For example, because you get access to a physical server, you can install a commercial operating system on it using a license that you already own.
If you’re new to AWS, or are launching a new application that has unpredictable resource needs, on-demand pricing is likely the best place to start.
However, once you become accustomed to the amount of resources your application requires, you can save money by using a different kind of EC2 pricing model that is tailored for your application’s situation.
Spot and reserved instances can also be useful if you are running a one-off workload, such as compiling a large body of source code, rather than hosting an application that needs to be available on an ongoing basis.
No matter what type of workload you want to host on EC2 -- whether it’s a traditional Web application, a high-performance database, a custom data analytics tool or virtually anything else -- there’s an EC2 instance to support it. Finding the best EC2 instance for your needs is as simple as understanding the different categories of EC2 instances, then identifying which special features, such as burstable performance or solid-state storage, you might want.
About the author