AWS EC2 Instances Types (all you need to know)
Tags: aws, ec2, devops, cloud
Published: 2024-04-01 03:24:03

I'm fully sure you have been involved at some point with EC2. In my opinion, this is probably the most important service for most of the AWS workloads. In almost all of the solutions architectures I have been involved, the most expensive cost is EC2. I have found a lot of times overprovisioned instances, cost optimization opportunities by changing the instances type or architecting your applications to work on ARM processors, or just workloads that can work better using a different family instance type, without compromising operational excellence and iptimizing costs. In this blog, I will guide you over all the details of ec2 instance types that you need to know to see these opportunities and optimize your operational costs.

---


## NITRO SYSTEM
before going deep into the instance types you need to know that aws built its own virtualization technology called **nytro system**. this is combination of hardware and software built for high performance, availability and security. offering capabilites "bare metal" a common myth with cloud virtualization si that the performance can be reduced compared with on-premises. **nytro system remove the layer of resources utilized by the common virtuzalization technologies** this is very useful for workloads that needs full access to the host hardware(later i will explain you what are the **bare** instances types). in words of aws documentation the perfomance is so close to bare metal that you can't notice the difference. the main components of nitro system are focused on the essential, remove common elements commonly used in other virtualization technologes. one of the main features is that it implements a card that externalizes the network, storage and security components of the hosts. removing that duty from the instance hardware. this nitro system is the underlying virtualization technology used for the last generation of ec2 instance that allow aws to have full control on the virtulizacion. i engourage you to take a look into this {% embed https://www.youtube.com/watch?v=Cxie0FgLogg&t=3s %} about the history of nitro and how it helped AWS to develop and offer a wide range of instances types without sacryfing perfomance, recuding costs, optimizing perfomance and offering a better security. even creating its own processors as the graviton instances giving to the client exactly the compute resources it asked for.  

---

## UNDERSTANDING THE EC2 INSTANCES TYPES AND ITS NOTATION 
{% cta https://aws.amazon.com/es/ec2/instance-types/  %} All EC2 instance types with details (current generation) {% endcta %}
Currently, we have two instance generations, the [previous](https://aws.amazon.com/es/ec2/previous-generation/) and the current generation powered by the Nitro system. You can still use the previous generation, but the recommendation is to use the latest.

### INSTANCES TYPES PRIMARY CATEGORIES

The use cases of the workloads running on EC2 can be very different. For this reason, the instance types are divided into categories allowing you to right-size your workloads either **horizontally** or **vertically**.

The type of instance selected at the time of launch will determine the hardware available for your application. Each type offers different capabilities such as memory, compute, storage, and network (sometimes these capabilities are combined, I'll explain later). Each of these instance types are categorized into groups or **families**.

- General Purpose: Offers a similar proportion of compute, memory, and networking. Ideal for apps that use these resources in a balanced proportion.
- Compute Optimized: Designed for apps with intensive CPU usage.
- Memory Optimized: Designed for high performance for apps/databases with high memory (RAM) usage such as cache databases.
- Storage Optimized: Designed for workloads with high I/O with high volumes of storage with optimized IOPS.
- Compute Accelerated: Optimized for instances that use hardware accelerators, or co-processors, to perform functions that will be performed more efficiently than is possible in software running on CPUs.
- HPC Optimized: Designed for HPC workloads at scale. My understanding of this topic is null so I can't provide more details.

---

## NOMENCLATURE CONVENTION 

EC2 currently offers a lot of different instance types and at the beginning, I know that it can be very confusing to decide which one makes more sense for your workloads. So let's make this easy for you. Let's get started by understanding the nomenclature. The type of instances is named based on its family, generation, processor family, additional capabilities, and size.

- The first position is the family. It can be `c`,`r`,`m`.
- The second position indicates the generation-version of the instance. Do not confuse this with the generation instances (previous or Nitro powered). **It's more like a versioning of the instance type**. generally a number (`5,6,7`).
- The third position indicates the family of the processor `g(graviton), a(amd), i(intel)`. The pending letters indicate the additional capabilities as volumes, networking capability, or characteristics of the CPU.
- **After the dot, it indicates the size of the instances as small, xlarge, or metal for bare metal instances**.

examples:

- c6gd.medium: In this case, the 'c' stands for compute-optimized family, '6' is the generation of this family, 'g' indicates that it's a Graviton, 'd' indicates it has additional storage, in most cases, an NVMe volume. Lastly, '.medium' is the instance size which, in this case, is 1 vCPU and 2 GB of RAM memory.

- c7gn.large: In this case, 'c' stands for compute optimized family, '7' indicates the generation of the family, 'g' represents that it uses graviton processors, 'n' indicates that it is network and EBS optimized. Lastly, '.large' is the instance size, in this case is 2 vCPUs and 4 GB of RAM memory.

- i3en.metal: Here, 'i' stands for storage-optimized family, '3' indicates the generation of the family, 'e' stands for extra storage or memory, 'n' indicates that it is network and EBS optimized. The 'metal' after the dot represents the instance size, which in this case refers to a bare metal instance, providing all the resources of the underlying server without nytro hypervisor, with bare metal instances you have the option to configure your own hypervisor, i haven't had any ooportunity to test this type of solution so i can't provide more details.

Once you understand this nomenclature, let's proceed with understanding the instance families. **Warning: This can be a lot of data, but I will not go deep into each instance family, just an overview to give you an idea.** 

---

### INSTANCE FAMILIES
- C - Compute Optimized: Optimized for workloads that require high usage of compute, ideally for applications with intensive use of CPU.
- D - Dense Storage: Designed for workloads that require large quantities of dense storage (HDD), ideally for warehousing.
- G - Graphics Intensive: Equipped with GPUs and optimized for workloads with intensive use of graphics, such as 3D, video streaming, or graphic design.
- HPC - High Performance Computing: Used for HPC workloads offering high networking throughput and compute capacity. I haven't seen workloads using this instance type and is a very specific topic out of my knowledge.
- I - Storage Optimized: Optimized for storage, ideally for databases or other types of applications that require high storage operation.
- Im - Storage optimized subcategory with a one to four ratio of vCPU to memory: This offers a specific proportion of vCPUs to memory, oriented for specific databases and storage applications.
- ls - Storage Optimized subcategory with a one to 6 ratio of vCPU to memory.
- Inf - AWS Inferentia: Designed for machine learning and inference. My knowledge of machine learning instances is null so I can't provide more details on this instance type.
- M - General Purpose: This is the most common instance type offering a proportional compute, memory, and network. Very used on web servers workloads.
- Mac - MacOS instances offering Mac instances, commonly used for Apple development applications.
- P - GPU acceleration: Offers GPUs and are optimized for parallel compute. I have seen workloads using this instance type for machine learning training models.
- R - Memory Optimized: For apps that need high memory usage, such as databases, big data apps.
- T - Burstable Performance: This type offers a good balance between cost and performance for workloads that don't use CPU constantly but at some point have spikes. This is done via credits that I will explain later.
- Trn - AWS Trainium: Especially designed for machine learning models. I don't know the difference between this, Inf, and P families.
- U - High Memory: Designed for applications that need large quantities of memory, such as databases. This makes me think about the difference against the R family.
- VT - Video Transcoding: Optimized for transcoding of video.
- X - Memory Intensive: Similar to the R family but fully focused on memory, made for workloads with extremely large quantities of memory.
- F - FPGA: Field Programmable Gate Arrays, I can't give a description of this because I don't fully understand its use.

i would like to create a better table presentation of the instance families but this is just a high level description, you don't need to kwow all of them at detail so it's up to you to dive deep into those that caugth your interest

## PROCESSOR FAMILIES
amd and intel has a line of processors specifically designed for servers under virtualization technologies, if you go to their websites you will find some of the processors that aws offers in the instances with a,i letters. there are some instances that doesn't have a processsor letter on its nomeclature which in most cases are intel processors, i don't know the context of this difference.

- a - AMD processors
- g - AWS Graviton processors: These instances use the Graviton processors created by AWS, based on ARM architecture. These offer a better cost-performance ratio compared to other processors of the same instance size, and can be more beneficial for some workloads.
- i - Intel processors


### ADDITIONAL CAPACITIES
- b - Block Storage Optimization: These instances are optimized for block storage (EBS), tripling throughput and EBS performance IOPS.
- d - Instance Store Volumes: Offers temporary storage directly attached to the host hardware, ideal for temporary data with high-speed performance as caches. In most cases, it's an NVMe ephemeral volume.
- e - Extra Storage or Memory: Indicates that the instance has high memory (RAM) capacity, which is useful for applications that need very high usage of RAM or very high storage (HDD).
- n - Networking and EBS Optimized: Offers high networking throughput and EBS, ideal for app workloads that require high network throughput.
- z - High Performance: Designed for high performance in general. Can include processors with specific capabilities, more GHz, better networking, and IOPS. 

**in some cases the addtitional capacities can be combined**, i just put here the most important ones, there asome other additonal capabilites that are just present in just a single instance so i don't see a high value in knowing them.

hey i know it's a lot of data and sincerely you don't need to know all of these but is very imporantnt to understand the notation of the intance types. save this post as **a cheatsheet to have when rigth-sizing your workloads**. at least on my experience i can say that is a very complex task to rigth-size your worloads and in most cases is more expensive to do a benchmark comparing different instances types than getting it done. for long-term solutions this is very beneficial combined with the purchase options available for EC2 that i'll explain in a different post of this serie

at this point i have some questions for you.
- what is the meaning of each letter? (select differnt examples from the list of the aws instances types)
- if i gave you any instance type of the most commonly used, are you able to know the meaning of its nomenclature?
- what is the nytro system?
- what are the different categories of instance families?
- what is the difference between a .bare metal instance and an instance with the same size not being .metal?

i missed something important to let you know and we are almost done...

lastly we have one of my favorites commonly used which are the {% cta https://aws.amazon.com/ec2/instance-types/?nc1=h_ls#Instance_Features %} burstable instances {% endcta %}

i encourage you to take a look into this link to have a detailed explanaition of it. i have seen some overprovisioned workloads where this instance type can be benefitial for those that can have some specific spikes of CPU usage and then lowering the usage for intermittent periods of time, i will explain later the use of ASG's and all the capabilities we have available with them in a different post. for comparing your instance selection the best tool that you can use is. 

---

{% embed https://instances.vantage.sh/ %} 
this tool allows you to compare different instances types and sizes at the same time.

thanks for arriving at the end of this post, i know a lot of us can think that we already know ec2, but knowing the details of the instance types will be very benefitial for those use-cases where you need to provide the best solution for a specific workload being cost-optimized without compromising the operational excellence.