EC2 are low-cost, reliable, and scalable virtual machines running on hardware provided by Amazon Web Services (AWS). Users only pay for how much they use an instance.
On-demand Instance: No upfront payment or long-term commitment. Users are charged on an hourly/second basis. Pricing varies on the capacity of the used instance.
Spot Instance: These spare EC2 computing capacities are offered for up to 90% off the on-demand price. Recommended for applications with flexible starting and ending times. Not suitable for mission-critical applications.
Reserved Instance: Upon using these instances, you get a discount of up to 72% compared to on-demand instances if you commit to a 1-year or 3-year term. Recommended for applications with long-term and steady use.
There are three types of reserved instances:
- Standard RI: It significantly discounts EC2 instance usage when you commit to a particular instance family.
- Convertible RI: You can change your instance configuration during the term and still receive a discount on EC2 usage.
- Scheduled RI: The user can reserve these instances on particular days or months. Recurring billing will be set for those instances.
EC2 Instance Types
EC2 instances are divided into the following types:
- General Purpose Instance (GPI)
- Compute Optimized Instance
- Memory-Optimized Instance
- Accelerated Computing Instance
- Storage Optimized Instance
General Purpose Instances (GPI)
GPI is a good choice if you are new to AWS or the cloud in general. These types of instances are utilized in services related to web servers, mobile, and game development environments or enterprise-level applications. GPI offer a wide balance of computing power, memory, and storage.
Another major distinction among general purpose instances is the use of fixed EC2 instance and burstable instance. The difference between burstable and fixed instances is that fixed instances provide fixed CPU resources, while burstable instances come with a “baseline” level of performance per vCPU. As long as the instance operates below the baseline level, it earns CPU credits.
Through CPU credits, you will not be charged as long as you are operating between the baseline level and the maximum capacity of the instance. If the credits are exhausted, you will be charged.
General-purpose Instance Types
- A1 instance: These instances are ARM based compared to others that use Intel or AMD processors. These instances are more suited for web servers, containerized microservices, and applications that run on open-source tools like java or python.
- M5 instance: One of the latest generations in the general purpose category, it contains the Intel Xeon Platinum 8175 3.1Ghz processor. These instances provide a balance between computing, networking, and memory. This instance type is ideal for small to medium-sized databases and data processing workloads. You can also use them as a backend server for applications like SAP or SharePoint.
- T3/ T3a instance: These instances have Intel and AMD processors and are available as burstable instances too. These are suitable as a cheaper and less powerful option as compared to M5 fixed instances. These are mostly used for long-lasting application instances like websites, web applications, scheduling jobs, and code repositories.
- Mac Instance: These instances allow to run on-demand macOS workloads in the cloud. By using Mac instances, you can develop apps for the iPhone, iPad, apple watch, apple TV, and safari. You can easily set up and access macOS environments within minutes, dynamically scale capacity as needed, and benefit from the pay-as-you-go pricing model. These instances are powered by AWS Nitro with core i7 processors, and all versions of macOS are available for use.
Compute Optimized instances
Compute Optimized Instances are suited to compute-intensive operations like image processing or mathematical operations. Compute-optimized instances provide high performance at a cost-effective price and are used widely in web servers, lightweight AI-based applications, and scientific modeling.
Compute Optimized Instance Types
- C5/ C5n instance: The C5 group of instances is suitable for applications like online gaming, machine learning, media transcoding, etc., which are compute-intensive tasks. With the C5d instances, you can physically connect the NVME-based SSD (non-volatile memory is a protocol used in SATA SSD, it is faster than legacy AHCI protocol) device to the host machine to provide block-level storage to the instance.
- C6/ C6g instance: These instances are equipped with the AWS Graviton2 processors and are used for highly intensive and advanced applications like high-performance computing, video encoding, and distributed analytics.
- HPC instance: This family of compute-optimized instances is used when running complex and large simulations and machine learning workloads in the cloud with a complete suite of high-performance computing products and services on AWS.
Memory Optimized instances
As the name implies, these instances are well-suited to memory-intensive workloads that need to process large datasets rapidly. Some example use cases include Big Data analytics or clusters running on Hadoop or Apache Spark.
Memory Optimized Instance Types
- R5/ R5a/ R5n instance: These instances are mostly used for workloads requiring high memory consumption like enterprise databases, big data analytics, large in-memory cache applications, etc. R5 and R5a instances are powered by Intel and AMD processors, respectively.
Compared to the previous R4 instance type, R5 instances offer 5% more memory with a 10% price improvement per GB over R4.
- R6g/ R6gd instance: Equipped with the AWS Graviton2 processor, these instances are ideal for high-memory workloads, including relational databases (e.g., MySQL) and in-memory caching (E.g., Redis). These instances use an AWS Graviton2 processor powered by a 64-bit ARM Neoverse core. The R6gd instance also comes with the capability of block-level storage because the local NVME-based SSD drive is connected to the host machine.
- X1/ X1e instance: Containing the Intel Xeon processors, these instances provide high computational memory for memory-rich applications, including SAP HANA, and Apache Spark, and high-performance computing. Compared to other EC2 instances, the X1e instance type offers the highest memory-to-compute ratio at the lowest price for each GB of RAM.
- High memory instance: These instances provide the highest capacity of RAM, and you can use these to run high in-memory databases like the SAP HANA database. These instances are only available on dedicated hosts.
Accelerated Computing Instances
These instances make use of additional hardware accelerators, including GPU and FPGA. These instances provide higher throughput in compute-intensive applications with more parallel processing. With GPU-powered instances, your applications can access NVIDIA GPUs with hundreds of computing cores.
FPGA-powered instances are equipped with large FPGAs with millions of logic cells for parallel processing. These instances are well-suited to applications that require parallel processing e.g., image processing, floating-point calculators, and data pattern matching.
Accelerated Computing Instance Types
- P3 instance: This is the latest generation of GPU-based instances and is equipped with a high-frequency Intel Xeon CPU.
- P2 instance: Well-suited for general-purpose GPU compute applications, these instances are powered by the Intel Xeon processor and come with high-performance NVIDIA GPU.
P2 instances provide high-performance networking and double-precision floating-point calculations. This instance type is best suited for deep-learning applications and high-performance databases.
- Inf1 instance: This instance features 16 AWS Inferential machine learning chips that provide low latency and cost-effective performance.
Inf1 instances come with Intel Xeon 2nd generation processors. It is well suited to API development where you want to use AWS Deep Learning APIs that are integrated with AWS Inferential.
- G3 instance: This instance is designed with the NVIDIA Tesla M60 GPU, and it provides a high-performance and cost-effective solution for graphic-intensive applications. It uses DirectX (available only for windows and used for drawing 3D graphics) or OpenGL(it is cross-platform and used for drawing 3D graphics). It is ideal for graphic rendering and streaming tasks. G3 instances contain the high-frequency Intel Xeon.
- G4 instance: G4 instance is powered by a 2nd generation Intel Xeon Scalable processor. This instance is suitable for accelerating machine learning inference and graphics-intensive applications. It contains the NVIDIA T4 Tensor Core GPU, so it supports the NVIDIA Grid Virtual Workstation feature.
- F1 instance: F1 instances feature hardware acceleration using FPGAs. These are powered with high-frequency Intel Xeon processor F1 instances, which feature NVME SSD storage and provide support for enhanced networking.
- Trn1 instance: It is powered by AWS Trainium chips, and they are purpose-built for high-performance deep learning training. It offers up to 50% cost-to-train savings as compared to GPU-based instance types. Trn1 instances deliver the best performance on deep learning training of NLP models in the whole AWS cloud. Organizations use Trn1 instances for NLP, computer vision, speech recognition, fraud detection, segmentation and classification of images/videos, etc.
- DL1 instance: Powered by Gaudi accelerators from Habana Labs, these instances deliver low-cost-to-train deep learning models for object detection, image recognition, and Natural language processing. DL1 instances provide up to 40% better price performance for training deep learning models compared to current generation GPU-based EC2 instances.
- VT1 instance: These instances accelerate real-time video transcoding while delivering low-cost transcoding for live video streams. They can reduce up to 30% cost per stream compared to G family GPU-based instances. Similarly, they offer up to 60% lower cost per stream compared to C5 CPU-based instances when transcoding live video calls.
Storage Optimized Instances
These are used for applications requiring high storage, particularly with sequential read and write needs. One example of such applications is log processing. These instances promise to deliver low latency at a high IO per second.
Storage-optimized instances are also suitable for cloud-native applications that contain high transaction and low latency workloads. Some use cases for these instances are in-memory databases, data warehousing, and data analytics.
Storage Optimized Instance Types
- D2 instance: Equipped with 48TB of HDD storage, D2 instances, come with high-density storage and high sequential read/write for large datasets, e.g., large Hadoop distributed environments. D2 instances offer the lowest cost per disk throughput as compared to all other EC2 instances. Hadoop clusters, log clusters, and data warehousing are some of their use cases.
- H1 instance: H1 instances provide lesser density storage with a maximum of 16TB HDD as compared to D2 instances. Equipped with an Intel Xeon processor, H1 instances promise to deliver high disk throughput and enhanced networking up to 25Gbps. These instances are suited for workloads requiring high throughput and sequential access to large datasets.
- l3/ l3en instance: These instances come with SSD storage that delivers lower latency as compared to HDD-based instances. These instances feature an NVME SSD storage that provides high input/output per second at low costs. You should use these instances for high-frequency OLTP systems, RDBMS, and caching for in-memory databases like Redis.
AWS EC2 Instance Types Comparison
Find below a brief comparison of different EC2 instance types:
EC2 Instance Pricing
The pricing of EC2 instances depends upon many factors. Let’s discuss these one by one.
One factor is the way EC2 is charged. Following are the three types of EC2 billing strategies.
- On-demand Instance
- Spot Instance
- Reserved Instance for a period of 1–3 years (full upfront, partial upfront)
Another factor is whether you want to go with hourly or per-second billing. AWS provides you with many options.
Another factor that determines that instance pricing is the instance itself. What family does the instance belong to — and in the family, what is the size of the instance? The following attributes decide the instance size and hence the cost.
- Any special feature like GPU or FPGA chipset attached to the instance
How to choose the right type of EC2 instance
Considering the many instance types offered by AWS, it is difficult for someone to select the right EC2 instance for a particular application. Here are the steps to make that journey easier:
Step 1 — Evaluate your application needs
First, you need to evaluate your application workload. Will it need more memory or more CPU? Does it need high input/output operations per second? Identify the needs in terms of the following parameters
After you have identified the needs in terms of the above attributes, the next step is to select the right instance family matching your needs.
Step 2 — Select the instance type family based on application needs
Now you need to select the instance type family suitable to your specific needs. As a general rule:
- Select “M” family for general purposes, including web servers and databases
- Select “C” family for compute-intensive workloads such as HPC, gaming, etc.
- Select “R” family for memory-intensive applications like enterprise databases, big data analytics, etc.
- Select “T” family for burstable workloads that are spikey in nature e.g., small databases, VDIs, etc.
Step 3 — Experiment with different instances sizes in the same instance family
After selecting an instance-type family, you should start with a basic instance in the same family and experiment with it. If it underperforms, upgrade to a better instance in the same family. Repeat it until you reach your desired instance size.
Real-World EC2 Usage Examples
Find below some examples of EC2 usage in the real world.
- A gaming company utilizes a fleet of C5 instances for online multiplayer games development
- A healthcare company uses Hpc6a compute-optimized instances for developing a deep learning based medical application for the classification and segmentation of medical images
- A social media company uses a fleet of R5 instances for big data analytics to develop a social media platform.
- A transport management system uses I3 instances to host their high-performance Oracle database to serve the needs of high IO workload.
In this article, we discussed different EC2 instances offered by Amazon Web services. We went through different instance types in detail and discussed the use cases for each instance family. As Amazon offers more than 400 instances, it may seem challenging at first to select the best EC2 instance for your specific needs. Having read this article, you should have now learned how to choose the EC2 instance that is best suited to your business and technical needs.