How To Understand and Choose Your First EC2 Instance on AWS
This article will help you understand what AWS EC2 instances are and then give you tips to follow when choosing your first instance.
Join the DZone community and get the full member experience.
Join For FreeEC2 instances on AWS are virtual servers that can be used to run applications and services on the AWS cloud. They are characterized by resources such as CPU, RAM, storage capacity, or even bandwidth.
Before you even begin exploring the different AWS EC2 instances, it is necessary to know your needs and your use cases. You will, therefore, first need to know your applications well and what configurations are necessary to make them work.
Several questions need to be asked to know what characteristics are necessary for your applications to run correctly. This includes knowing the operating system, as well as the quantities you need for the following resources:
- vCPU: These are the cores of the processor and, therefore, its power (the calculation unit of the processor being a core). The more cores there are, the more or larger tasks the processor can perform, and the higher the performance will be when performing calculations.
- GPU: It is the graphics processor that normally performs image calculations, but these can also be interesting for carrying out calculations requiring higher performance than that of the CPU.
- RAM: This is the RAM that allows information to be stored while the CPU does the calculations. The higher the RAM, the faster the CPU will be able to access the data necessary to carry out its calculations.
- Storage space: The more the application is based on large files or many small files, the larger it will need to be.
- Network bandwidth: Consider if your application performs a lot of network operations (data download/upload, API contact, etc.)
You may also be asked other questions about your use cases, such as the geographic area you are targeting to run your applications. This can be useful in cases, for example:
- To limit latency for your end users. Indeed, it is better to host an application intended for a European audience in Europe rather than in North America.
- To comply with certain legislation if you host health data and, in particular, wish to obtain your HDS certification.
Understanding the Different Instances of Families
Now that you know more about your use cases and applications, you can look into the different types of EC2 offered by AWS!
AWS offers a classification into five main families, which are as follows:
1. Versatile: These are the most balanced instances between the different resources; they present a good compromise between CPU, RAM, network speed, etc. These are generally those that are used to host websites and/or to get started.
2. Optimized calculation: They emphasize processor performance. They can, therefore, perform a large number of calculations and are ideal for scientific modeling or any other application requiring intensive calculation.
3. Optimized memory: These are the instances that have the highest RAM. allow high-speed access to data stored in RAM. If you need quick access to a large database, then they will be ideal.
4. Accelerated calculation. These EC2s are similar to Optimized Compute but use GPUs. They, therefore, have even greater computing capacities. They can be used for machine learning applications, for example.
5. Optimized storage. If access to large amounts of data is important to you, then these instances may be ideal. They are designed for workloads that require high access and bandwidth to a large volume of storage.
These are general factors that will allow you to make an initial selection and direct you toward the AWS EC2 instances that seem to be the most suited to your uses. But once the most appropriate family has been selected, you will need to look at which instance will best suit your needs. And it won't be an easy task!
Understanding Instances
Once you have identified the family that seems to best suit your needs, you can look into choosing the one that will meet your needs. The characteristics of your applications determined in the first chapter will help you choose the AWS EC2 that suits you best.
You will then find yourself faced with many names, such as T2.micro, R6a.large, or even X2iedn.4xlarge. These nouns may seem complex to understand, but they are constructed as follows:
- The first letter corresponds to an instance category.
- The next number corresponds to the generation of the category (T3 is, therefore, a more recent generation than T2).
- The last letters, for their part, will indicate if the instance type is optimized and for what (thus, R6a has an a to indicate that it is powered by AMD processes and that it is optimized for heavy loads of work in terms of memory).
- The names following the point determine the size of the EC2 (and therefore its characteristics of number of vCPUs, quantity of RAM, etc.). This size can range from nano to 32xlarge.
Let's now explain how to read the AWS EC2 instances that we mentioned previously:
T2.micro is a general-purpose instance of the 2nd generation T category (there are T3 and T4) and has a micro size. It has, among other things, the following characteristics:
1 vCPU
1 GiB of RAM
R6a.large is a memory-optimized instance of the 6th generation R category (there are R4, R5, R6 and R7). This has a 3rd generation AMD EPYC processor (hence the “a”). It has, among other things, the following characteristics:
2 vCPUs
16 GB of RAM
up to 12.5 Gbps network bandwidth
X2iedn.4xlarge is a memory-optimized 2nd Generation. It has, among other things, the following characteristics:
16 vCPU
512 GB of RAM
25 Gbps network bandwidth
475GB instance storage
Practical Case of Choosing Instances
Let's now move on to some practical cases to understand how to put this into practice.
A technology enthusiast wants to host his tech blog on AWS. To choose his EC2, he will follow the following reasoning:
- He knows that his site receives around 100 simultaneous visitors at most.
- So he will need an instance with enough CPU to handle simultaneous connections, but he also wants to have versatility. It is, therefore, moving towards a multi-purpose instance.
- He anticipates an increase in the load on his site as he works in parallel on the visibility of his site. He estimates that the number of visitors will triple in 3 months. This forecast, as well as the pricing criteria, mean that he will choose the t3.small, which is a little larger than his current needs.
He could have opted for other simpler solutions, such as CloudFront, but he still chose an EC2 instance because he uses many other services offered by AWS.
Company X has created an application that allows you to quickly consult the health data of its members. To choose well, they will follow the following reasoning:
- It is expected that the app will provide access to a lot of data and that it will need to keep this data in memory.
- It is, therefore, logical to move towards a family of optimized memories.
- A good balance between the necessary characteristics (number of users, volume of data to process) and pricing allowed them to choose the r5a.8xlarge instance.
Anxious to comply with HDS standards, they will also be forced to rent EC2 AWS instances in Europe, and more precisely, in the “eu-west-3” zone.
Conclusion
There are so many AWS EC2 instances that it will take you some time to familiarize yourself with all of them, but you now have a better understanding of what Amazon Web Services offers. The most recommended to start with (and also eligible for the free offer) is the t2.micro instance. Depending on your use case and the evolution of your applications, you may need to use others with higher specifications.
If, once your choice has been made, you need to increase the capacities of your instances, you can easily choose a new, more powerful type of EC2 or add new instances in parallel. Solutions such as Kubernetes, Karpenter, or even autoscaling can help you scale your instances to best meet your needs.
Opinions expressed by DZone contributors are their own.
Comments