AWS EC2 Instance Types

Learn via video courses

Overview

AWS has a huge catalog of EC2 Instance Types for you to choose from depending on your needs. These instance types vary by the number of CPU cores, memory, network bandwidth, and so many other factors. Although it may seem daunting to choose the correct instance type, there are a few points you use to make this process easier and more cost effective.

Amazon EC2 Instance

Amazon EC2 is a virtualization service provided by AWS. Amazon EC2 allows you to create virtual machines, known as "EC2 Instances". AWS gives you full control over choosing which operating system to run, and provides a list of pre-configured hardware specifications which are called EC2 Instance Types. We will be taking a look at these EC2 Instance Types in the next section.

EC2 Instance Types

When you are creating an Amazon EC2 Instance, AWS will provide you with a list of hardware configurations (number of CPU cores, memory, disk space, etc.), which are called AWS EC2 Instance Types. As of writing this article, there are over 500 instance types to choose from!

Choosing an EC2 Instance Type is similar to shopping for a laptop. Imagine you are trying to buy a laptop for your college or workplace. You need to consider which Operating System you want to use - Windows or Linux or Mac OS. Then you also need to choose the number of CPU Cores (2, 4, 6 etc.) and amount of Memory/RAM (4 GB, 8 GB etc.). And maybe you want some extra configurations like a Graphics Card/GPU to play games. Once you know what your requirements are you will shop around and pick a laptop that fits your Budget. Let's look at the different AWS EC2 Instance Types and understand how to pick the right instance type as per your needs.

General Purpose EC2 Instance

General Purpose EC2 Instance 1 General Purpose EC2 Instance 2 General Purpose EC2 Instances provide a balanced distribution of CPU cores, memory, and networking resources. These instances can be used for workloads that do not require high utilization of any one particular resource.

M5 Instance

  • Covers most "balanced" use cases and can be used for a wide range of applications
  • Can be used for small to midsize databases, backend servers
  • Examples: m5.large (2 CPU cores, 8 GB of memory), m5.xlarge (4 CPU cores, 16 GB of memory)

T3 / T3a Instance

  • Entry-level instances for "simple" use cases
  • Can be used for websites, testing/staging environments
  • Part of AWS's Free Tier (t3.micro)
  • Examples: t3.micro (2 CPU cores, 1 GB of memory), t3.medium (2 CPU cores, 4 GB of memory)
  • T3a Instances use AMD EPYC Processors whereas T3 Instances use the standard Intel Xeon Processors

A1 Instance

  • Uses AWS's custom ARM Processor Graviton
  • Can be used instead of T3/T3a instances when using ARM is a requirement
  • Examples: a1.medium (1 CPU core, 2 GB of memory), a1.large (2 CPU cores, 4 GB of memory)

Compute Optimized

Compute Optimized

Computer OptimizedEC2Instances provide a higher number of CPU cores compared to other resources. These instances can be used for workloads that require high compute or CPU utilization.

C5 / C5n / C5a Instance

  • Cost-effective, high performance for running compute-intense workloads
  • Can be used for batch processing, media transcoding, and high performance web servers
  • Examples: c5.xlarge (4 cores, 8 GB of memory), c5.4xlarge (16 cores, 32 GB of memory)
  • C5n provide increased memory and network bandwidth (up to 100 Gbps) compared to their C5 counterparts
  • C5a Instances use AMD EPYC Processors whereas C5/C5n Instances use the standard Intel Xeon Processors C6g Instance
  • Uses AWS's custom ARM Processor Graviton2
  • Can be used instead of C5 instances when using ARM is a requirement - also provide 40% better price to performance compared to C5 instances
  • Examples: c6g.xlarge (4 cores, 8 GB of memory), c6g.4xlarge (16 cores, 32 GB of memory)

Memory Optimized

Memory Optimized Memory Optimized EC2 Instances provide a higher allocation of memory compared to other resources. These instances can be used for workloads that require high memory or RAM utilization.

R5 / R5n / R5a Instance

  • Designed to deliver fast performance for workloads that process large data sets in memory
  • Can be used for different types of databases - relational (MySQL), NoSQL (MongoDB, Cassandra), or in-memory (Redis)
  • Also can be used for real time processing of big unstructured data along with Apache Hadoop/Spark
  • Examples: r5.xlarge (4 cores, 32 GB of memory), r5.4xlarge (16 cores, 128 GB of memory)
  • R5n boosts the available network bandwidth to up to 100 Gbps and can be used where both memory and network performance is critical
  • R5a Instances use AMD EPYC Processors whereas R5/R5n Instances use the standard Intel Xeon Processors

R6g Instance

  • Uses AWS's custom ARM Processor Graviton2
  • Can be used instead of R5 instances when using ARM is a requirement - also provide 40% better price to performance compared to R5 instances
  • Examples: r6g.xlarge (4 cores, 32 GB of memory), r6g.4xlarge (16 cores, 128 GB of memory)

X1 / X1e Instance

  • Instances offering up to a whopping 3904 GB of memory
  • Can be used for large-scale enterprise applications and in-memory databases like SAP HANA
  • Examples: x1.32xlarge (128 cores, 1952 GB of memory), x1e.32xlarge (128 cores, 3904 GB of memory)

Accelerated Computing

Accelerated Computing Accelerated Computing EC2 Instances are a unique set of instance types that use specialized hardware accelerators or co-processors. These instances are used for a wide range of operations like graphics processing, machine learning, or high performance computing.

P3 / P2 Instance

  • Designed for general purpose GPU computing using the CUDA or OpenCL programming models or through a machine learning framework.
  • Use NVIDIA Tesla V100 GPUs (P3) and NVIDIA K80 GPUs (P2) which provide powerful half, single, and double-precision floating-point capabilities
  • Can be used for high performance computing, computational fluid dynamics, and autonomous vehicles
  • Examples: p3.16xlarge (64 CPU cores, 488 GB of memory, 8 GPU cores, 128 GB of GPU memory)

G4 / G3 Instance

  • Offer high performance for graphics-intensive applications such as remote workstations, video rendering, and deep learning models.
  • Feature up to 8 NVIDIA T4 Tensor Core GPUs
  • Can be used for high fidelity cloud gaming, GPU intensive video rendering, and training for deep learning models
  • Examples: g3.16xlarge (64 CPU cores, 488 GB of memory, 4 GPU cores, 32 GB of GPU memory)

Inf1 Instance

  • These instances are designed to accelerate machine learning using AWS Inferentia, a custom AI/ML chip from Amazon that provides high performance and low latency machine learning inference.
  • Can be used for deploying deep learning models, image/video analysis, and recommendation engines
  • Deliver up to 2.3x higher throughput and up to 70% lower cost per inference than comparable current generation GPU-based Amazon EC2 instances
  • Examples: inf1.6xlarge (24 CPU cores, 48 GB of memory, 4 Inferentia Chips)

F1 Instance

  • Provide customizable hardware acceleration with Field Programmable Gate Arrays (FPGAs), which are required for highly parallel operations not suited for general purpose CPUs
  • F1 instances use Xilinx UltraScale+ VU9P FPGA, which each has approximately 2.5 million logic elements
  • Can be used for genomics and financial analysis
  • Examples: f1.16xlarge (64 CPU cores, 976 GB of memory, 8 FPGAs)

Storage Optimized

Storage Optimized

Storage Optimized EC2 Instances provide a higher sequential read/write access to local storage compared to other resources. These instances can be used for workloads that depend on highly performant read/write operations with large storage devices.

I3 / I3en Instance

  • Designed for workloads requiring high read/write transactions and low latency, up to 60 of NVMe SSD storage
  • These instances typically include a Non-Volatile Memory Express (NVMe) SSD-based storage, attached as a secondary storage volume
  • Can be used to host in-memory databases like Aerospike or Redis
  • Also can be used as a cache or a distributed file system
  • Examples: i3.xlarge (2 cores, ~16 GB of memory, 475 GB NVMe SSD), i3.2xlarge (4 cores, ~32 GB of memory, 1900 GB NVMe SSD)
  • I3en instances come with up to 100 Gbps networking bandwidth

D2 Instance

  • Specialized for workloads that require massive scale while at the same time being distributed, up to 48 TB of HDD storage
  • Can be used for large data lakes or distributed file systems (HDFS)
  • Examples: d2.8xlarge (36 cores, 244 GB of memory, 48 TB of HDD)

H1 instance

  • For workloads that require low cost, high disk throughput to very large data sets - offers the best price/performance for instances with HDDs
  • Can be used instead of I3/D3 instances where pricing is a higher priority than performance
  • Examples: h1.2xlarge (8 cores, 32 GB of memory, 2000 GB HDD), h1.8xlarge (32 cores, 128 GB of memory, 8000 GB HDD).

Choosing EC2 Instance Types

Choosing an EC2 Instance Type comes down to two steps, which have been outlined below.

1) Make a Selection As Per Your Requirements

The first step in choosing the appropriate EC2 Instance Type is listing down your hardware requirements:

  1. Number of CPU cores
  2. Amount of Memory (RAM)
  3. Network Bandwidth
  4. Is any extra Storage required? SSD or HDD?
  5. Are any co-processors required? GPU or FPGAs?

Then pick the EC2 Instance Type from the family of instance types provided by AWS. You can first pick the Type based on your overall needs, and then choose a Sub-Type that is closest to the requirements you have outlined. AWS provides a comprehensive list of all the available instance types here.

Don't worry if your choice is the most cost effective or not, we will take care of that in the next section.

AWS provides over 500 different instance types! Here's a quick reference to the different AWS EC2 Instance Types we discussed earlier:

TypeHardware CharacteristicsSub-Types
General PurposeBalanced distribution of hardwareT3, M5
Compute OptimizedHigher distribution of CPU coresC5, C6g
Memory OptimizedHigher distribution of MemoryR5, X1
Storage OptimizedIncludes high throughput storageI3, D3
Accelerated ComputingIncludes co-processors like GPUsG3, Inf1

2) Apply Cost Optimizations With The Help of AWS

Now that you have chosen your instance type, let's see how you can optimize your choice to be cost effective and reduce your monthly bill by the most amount. All of these optimizations can be done within the AWS Console, so you don't need to depend on external services to save costs.

AWS Cost Optimizer AWS Cost Optimizer is a service provided by AWS that provides recommendations based on resource utilization. This service observes the usage patterns of an EC2 instance and provides recommendations on alternate instance types that perform similarly for a lower cost.

If you have over-provisioned your EC2 instance(s), you can change the instance type using the AWS Console. Be careful of the caveats of changing instance types though!

AWS Pricing Models AWS provides multiple purchasing options to enable you to optimize your costs.

By default, you pay for every second the moment you launch an EC2 instance, which is known as On-Demand Pricing. But if you know your application's usage patterns you can use the below alternate pricing models to save on costs.

Savings Plans: Reduce your Amazon EC2 costs by making a commitment to a consistent amount of usage, in USD per hour, for a term of 1 or 3 years.

Reserved Instances: Reduce your Amazon EC2 costs by making a commitment to a consistent instance configuration, including instance type and Region, for a term of 1 or 3 years.

Spot Instances: Request unused EC2 instances, which can reduce your Amazon EC2 costs significantly. Spot instances offer the most lucrative discounts, and you can choose to run Spot Instances even for your Production workloads, depending on how your application handles interruptions.

Optimize Storage and Elastic IPs Usage An optimization you can apply is picking only the right storage specification for your EC2 instance's root volume and secondary volume(s).

AWS Elastic Block Storage (EBS) is the storage solution used for EC2 instances. EBS is charged separately and even gets charged when your EC2 instance is shut down! Make sure you have chosen only the required size for your volume(s), and also choose more cost-effective options like "gp3" instead of "gp2".

Another optimization you can apply is de-attaching any Elastic IP Addresses if your EC2 instances do not need to be part of an internet-facing network/subnet. Elastic IP addresses also are charged separately by the hour.

Conclusion

  • In this article, we learned about the different AWS EC2 Instance Types, and how to choose the right instance type for your use case.
  • Similar to choosing a laptop, you need to make a list of your hardware requirements - like the number of CPU cores, amount of memory, etc.
  • Then pick a Type that broadly matches your usage goals from General Purpose Instances, Compute Optimized, Memory Optimized, Storage Optimized, or Accelerated Computing.
  • Once you have selected a Type, pick a Sub-Type that is closest to your requirements. AWS provides over 500 of these Sub-Types!
  • Finally, we learned how to make cost optimizations using AWS Cost Optimizer, picking a better Pricing Model, or making other optimizations on Storage/Elastic IPs.