When I use the amazon AWS ec2 virtual machine, I always find the virtual machine runs too slow. I open the task manager and found that the CPU usage always reaches 100%, this is the root cause of the slow VM. But at last, I find the real reason is because of the AWS EC2 instance type. This article will tell you how to fix it.
1. How To Choose High-Performance AWS EC2 Instance Type For You To Run Faster.
- You can go to the link https://aws.amazon.com/ec2/instance-types/ to see all the AWS EC2 instance types.
- Among all the types, we should pay special attention to the T type (t2. t3. t3a. t4g .etc.).
- The T type AWS EC2 instance is also called burstable performance instances type.
- Their price may be cheap than other types, but their CPU usage is also limited.
- When you start to run the T-type EC2 VM, it begins to earn the credits for you, but you can just use a percentage of the CPU capacity, not the full CPU capacity.
- For example, for the t3.micro instance type, when you start it, you earn credit, but the credit can only give your 20% of the CPU capacity to use.
- When your VM server is idle at night, that means the CPU usage is less than 20%, then your VM can earn credits over the night.
- When you wake up in the morning and start to use the VM, the CPU usage is more than 20%, then your VM starts to spend the credits to keep the CPU usage.
- When all the credits the VM has earned are used, then your VM CPU will run very slowly.
- But AWS provides you an option to buy more credits, you can configure this option on the AWS EC2 instance configuration page.
- Log in to the AWS management console and go to the instances list page, select the EC2 instance by checking the checkbox before the EC2 instance.
- Click the Actions drop-down list on the page top right area, then click Instance Settings —> Change credit specification menu item.
- Then it will open the Credit specification page, check the checkbox under the text Enable unlimited mode, and click the Save button to save it.
- Now your AWS EC2 instance can buy credits to use more percentage of the CPU usage when the credits are not enough.
- The credit buying fee for Linux is 0.05$/hour, and for Windows is 0.095$/hour.
- The AWS EC2 instance’s credit specification attribute has 2 values, they are standard mode & unlimited mode.
- The t2 type AWS EC2 instance default set the standard mode, and the t3, t3a type AWS EC2 instance default set the unlimited mode.
- In the standard mode, the VM can earn credits when in idle time ( CPU usage is lower than the baseline usage).
- In the unlimited mode, the VM can earn credits when in idle time ( CPU usage is lower than the baseline usage) and also can buy credits when needed.
- You can change the AWS EC2 instance credit specification mode at any time.
2.1 When To Use AWS EC2 T Type Instance.
- If you use the AWS EC2 VM for a long time and most of the time the VM is idle, then you can choose the T type.
- When you do not use the VM, close all the applications on it to male lower CPU usage to earn credits.
- Then when you use it again, you can use more CPU percentage by the credits you have earned.
- If you use AWS EC2 T type instance in unlimited credit specification mode, it may not be cheap.
- Because the cost needs to add 0.05$/hour (Linux) and 0.095$/hour (Windows).
- This method should be used for AWS free tier in standard credit specification mode.
- Because the free tier is totally free and when you do not need to use the VM ( for example when you go to sleep at the night or when you go to exercise or have lunch ), you can close all the applications in the AWS EC2 VM and let it run in idle mode, then it can earn more credits for you.
- But if you find it runs slowly, you can change the EC2 instance credit specification attribute value to unlimited mode to make it run faster which may cost some money.
- When you do not need to use it, you can change the EC2 instance credit specification attribute value back to standard mode again to save money.
- In this way, you can make your work faster by using the full capacity of the CPU and cost less money.
- Another use case that can use the T type instance is that when you host a web server on it, and the webserver is not busy for the whole day, most of the day there is less traffic to your webserver. In such a case, if you choose the unlimited mode for the credit specification, it can also save some money while giving your web server enough CPU capacity.
2.2 When To Use Other AWS EC2 Instance Type.
- When you do not need to use the AWS EC2 VM for a long time such as using it for 5 hours every day.
- You had better use other instance types such as a type, c type .etc.
- Those types will give you full CPU capacity to use.
2.3 Where To Find Your EC2 Instance Credit Data & CPU Usage.
- AWS provides a dashboard for you to monitor your EC2 instance data, including credit specification mode, CPU utilization (usage) (%), CPU credit usage (count), and CPU credit balance (count).
- Log in to your AWS management console, and click the Instances link on the page left side to go to the instances list page.
- Check the checkbox before an EC2 instance to select it.
- Click the Details tab below the EC2 instances list.
- You can search the keyword credit specification on the page, then you can find the credit specification mode.
- Click the Monitoring tab, it will list a lot of charts on the page, the chart includes CPU utilization (usage) (%), CPU credit usage (count), and CPU credit balance (count).
- UNDERSTANDING T2 AND T3 CPU CREDITS IN AWS.
Key concepts and definitions for burstable performance instances.