Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS RDS t2.medium CPU credits low although CPU not high

I'm wrapping my head around this issue with the CPU Balance constantly going down although my CPU during this time is <40% consistently.

I'm using a t2.medium with MySQL and according to this page, shouldn't it be that if I'm <40%, my CPU Credits will increase?

Ref: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/t2-instances.html

CPU <40%, Credits depleting

like image 553
Sergiu Poenaru Avatar asked Jan 06 '23 05:01

Sergiu Poenaru


1 Answers

The baseline performance of a t2.medium is 40% CPU utilization on a scale of 0% to 200%, because the machine has 2 cores.

On a scale of 0% to 100%, like the one shown in Cloudwatch, it's 20%.

This can be illustrated with the following calculations:

A single core running at 100% consumes 60 credits per hour (1 credit per minute). This is the definition of a CPU credit.

One CPU credit is equal to one vCPU running at 100% utilization for one minute. Other combinations of vCPUs, utilization, and time are also equal to one CPU credit; for example, one vCPU running at 50% utilization for two minutes or two vCPUs running at 25% utilization for two minutes.

Two cores both running at 100% consume 120 credits per hour (1 credit per minute per core = 2 credits per minute).

A t2.medium earns 24 credits per hour.

The baseline performance is directly related to the rate at which credits are earned... and 24 credits means 24 minutes of 100% utilization of one core.

Therefore, the maximum sustained utilization to prevent the balance from continually approaching zero is one of these:

  • 24 ÷ 60 = 40% (one core using this much, the other core idle)

  • 24 ÷ 120 = 20% (both cores using this much, each)

...or any combination, such as 10% of one core and 30% of the other.

If this gives you the impression that there's something disingenuous going on... there isn't: the baseline of the t2.small (a single core machine) is 20% of 1 core. The baseline of the t2.medium (at twice the price) is twice that much -- 40% of 1 core or 20% each of 2 cores.

like image 91
Michael - sqlbot Avatar answered Jan 16 '23 21:01

Michael - sqlbot