Sergiu Poenaru
Sergiu Poenaru

Reputation: 149

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

Upvotes: 6

Views: 3093

Answers (2)

Michael - sqlbot
Michael - sqlbot

Reputation: 178966

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.

Upvotes: 11

Vorsprung
Vorsprung

Reputation: 34297

The credits are used when the CPU spikes

Perhaps you are getting spikes that are too short lived to show up on the cpu graph but which are draining your credits

I would suggest using a larger instance type with more ram. With only 1 or 2 connections the system shouldn't be even going up to 40%. It might be swapping activity that is affecting the CPU use

What does the swap usage show? I am guessing that some swap is being used and this is what is making your systems performance less than ideal

Upvotes: 0

Related Questions