🐾How to choose appropriate EC2 instance type?🐾
🤓 Do you struggle with choosing the most effective EC2 instance type? It’s great when you have detailed technical requirements for your application, but what if you don’t? AWS provides you with a wide variety of EC2 instance types, so it’s easy to get lost in choosing the right one.
I would say if you don’t know anything about your application resource usage - start with general-purpose instances, such as the M family. After that, you can start monitoring metrics and discovering application usage patterns. While monitoring your application utilization, you can adjust instance family and size based on utilization metrics. CPU and memory utilization are the first metrics I monitor to check whether I selected an appropriate instance type.
In order to get memory utilization metrics from your EC2, you should install the CloudWatch agent. Detailed instruction on how to do that is described in official documentation.
There are five main situations you might find yourself in:
1️⃣ Both CPU and memory on average are utilized up to 80%
It’s a good sign that you choose the correct instance type and efficiently utilize resources. You can have spikes higher than 80% in this case, but ensure that: 1) it’s not a permanent utilization, 2) the application shouldn’t fail during spikes and 3) utilization during these spikes is lower than 90%.
If you see periodical spikes only in CPU usage, I would recommend T family, as it has the ability to burst CPU and utilkize CPU credits for that.
2️⃣ CPU utilization is under 50% and memory utilization is up to 80%
It’s a sign that your application is memory-intensive and you should switch to memory-optimized instance families. The good start is R family.
3️⃣ CPU utilization is up to 80% and memory utilization is under 50%
It’s a sign that your application is compute-intensive and you should switch to compute-optimized instance families. The good start is C family.
4️⃣ Both CPU and memory utilization are utilized below 50%
It’s a sign that you can reduce instance size from, for example, large to medium.
5️⃣ Both CPU and memory utilization are utilized up to 99%
It’s a sign that you should increase your instance size
Thank you for reading, let’s chat 💬
💬 Do you have any tips for choosing an instance family?
💬 Which metrics do you use to decide on instance type?
💬 Any interesting stories about instance type optimization?
I love hearing from readers 🫶🏻 Please feel free to drop comments, questions, and opinions below👇🏻