Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS EC2 instance reboot loses all CPU credits

Tags:

amazon-ec2

Recently I was required to reboot my EC2 instance due to an AWS maintenance alert. After reboot I noticed my CPU credit balance was consumed. Why is that? What's going on?

EC2 instance CPU usage & credit balance

like image 435
Dan Avatar asked Nov 05 '17 19:11

Dan


1 Answers

Stopping and Starting a t2-standard class instance moves your instance to a new host system, clears your credit balance and then ordinarily¹ gives you a baseline of 30 credits per vCPU to ensure a smooth start-up.

T2 Standard instances get 30 launch credits per vCPU at launch or start. For example, a t2.micro has one vCPU and gets 30 launch credits, while a t2.xlarge has four vCPUs and gets 120 launch credits.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-std.html

Rebooting doesn't do this, but restarting (that is, a stop followed by a start) does, and the stop/start required for most maintenance events is a restart, not a reboot.

Tip

To ensure that your workloads always get the performance they need, switch to T2 Unlimited or consider using a larger T2 instance size.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-std.html

T2 unlimited machines are allowed to borrow against future CPU credit earnings for the upcoming 24 hours, so they don't receive the initial credit balance. You aren't charged extra for these borrowed credits, unless your workload is so heavy that over the subsequent 24 hour period is you continue to use credits at a rate that causes you to spend more than you could have earned.


¹ordinarily unless you have performed more than 100 stop/starts or launches of more than 100 t2-standard machines in the past 24 hours or your account is new, to prevent gaming the system. New accounts gradually ramp up to the 100 threshold.

like image 195
Michael - sqlbot Avatar answered Oct 06 '22 08:10

Michael - sqlbot