How much time do I have left before my instance runs out of CPU credits?

I like T2 EC2 instances. They help me save money while they also guarantee that my applications can handle bursts in traffic. However, if you are using T2 instance types you have to understand CPU credits. Otherwise you might encounter some unwelcome surprises… and nobody likes unwelcome surprises!

To summarize CPU credits:

  • CPU Credits only apply to T2 EC2 instance types. If you are running M3, M4, C3, C4 or others you don’t have to worry about CPU credits.
  • 1 CPU Credit = 1 vCPU running at 100% for 1 minute.
  • Instances earn a set rate of CPU credits over time, regardless of usage.
  • Instances have a baseline CPU % consumption. Usage above this rate results in CPU Credit depletion.
  • Instances receive a base number of CPU credits at launch.
  • If unused, earned CPU credits expire after 24 hours.
  • If you deplete your CPU credits, the instance performance will be capped at the baseline CPU value (for example, 5% for a t2.micro). If you reach this point, your application is presumably experiencing high-traffic. In this case, having a cap on your instance performance means there will be degradation in your application’s speed and throughput. Your customers will not like this.
  • T2 types (i.e. t2.nano, t2.micro, t2.small, etc.) have different values for initial credit, baseline, earn rate and maximum balance.

I find the concept of CPU credits useful, but not very straightforward. That’s why I put together this cheatsheet that tells me how much time I have before my instance runs out of CPU credits.

Am I running out of CPU credits?

And here is a PDF version, please feel free to download it.

I recommend monitoring CPU Credits in CloudWatch and setting up alarms when your credit balance becomes dangerously low. Even better, you could configure an Autoscaling group so that it launches a new instance when your CPU credit is low or when your CPU usage is above a certain value for a period of time.

The table in this post should help you decide the right value.

Ernesto Marquez

ErnestoMarquezProfilePic

I am the Project Director at Concurrency Labs Ltd, ex-Amazon (AWS), Certified AWS Solutions Architect and I want to help you run AWS optimally, so your applications reliably generate revenue for your business.

Running an optimal AWS infrastructure is complicated - that's why I follow a methodology that makes it simpler to run applications that will support your business growth.

Do you want to learn more? Do you have other questions related to AWS? Click on the button below to schedule a free 30-minute consultation.

Do you have any comments or questions about this post, or my services?