2

I have a t2.micro instance running Ubuntu Linux on ec2 in Ireland, it's running batch jobs and I've tuned them so that the max CPU is pretty low - it never exceeds 10%.

The docs say that:

When a T2 instance uses fewer CPU resources than its base performance level allows (such as when it is idle), the unused CPU credits (or the difference between what was earned and what was spent) are stored in the credit balance for up to 24 hours, building CPU credits for bursting. When your T2 instance requires more CPU resources than its base performance level allows, it uses credits from the CPU credit balance to burst up to 100% utilization.

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

The same page also says that "Base performance (CPU utilization)" for this type of instance is 10%.

But when CPU usage is around the 6% level - always with the max remaining below 10% - the instance consumes CPU credits. Which is not what I expected, because I understand the the docs (quoted above) to say that when the instance is at or below its base performance level, it doesn't consume any CPU credits. (I'm getting the CPU usage figure from Cloudwatch basic monitoring).

So why is the instance consuming CPU credits?

1

It's still consuming credits, it's just getting new credits at the same rate or faster than it uses them up.

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.

So, for a t2.micro, you'll get six credits per hour (one every ten minutes). At 10% load, you'll burn six credits per hour (again, one every ten minutes).

Think of it like being paid for work and having to pay rent. Your job doesn't pay your rent directly and just give you a $0 paycheck - they give you money, which you then pay your rent with. If you earn more than your rent, your bank account goes up. If you earn less than your rent, eventually you run out of money.

  • Makes sense - but since the instance is always below 10% (sometimes it's totally idle) shouldn't there be a net increase in credits over time? Credit balance doesn't increase even for periods where CPU is 0 and credit usage is 0. (Credit balance is not maxed-out at 144, it's around 125 right now). – A E Jun 21 '16 at 13:22
  • @AE How many CPU credits do you have? Once you get to 144 you won't get any more. See the "Maximum earned CPU credit balance" column in the docs. – ceejayoz Jun 21 '16 at 13:24
  • I was thinking you might think that, amended my comment above already. ;) 24 hours ago it was maxed out at 144 (i.e. it wasn't gaining credits 24 hours ago because it was at max already), maybe the effect has something to do with the 24-hour expiry rule. – A E Jun 21 '16 at 13:24
  • @AE Yeah, I'd keep an eye on it for a day or so and make sure it doesn't trend downwards. If it does, you're in the realm of AWS support tickets. – ceejayoz Jun 21 '16 at 13:33
  • 1
    If it was completely idle 24 hours ago, the credit balance will "hover." This is normal and the cause is exactly as you speculated -- a side-effect of the 24 hour expiration rule. I wrote an amusingly-detailed analysis of this behavior on Stack Overflow. The most-recently-earned credits are spent first, not last, which at first glance doesn't seem to be significant, but it turns out to be, because the unused old credits from exactly 24 hours ago expire as you earn new ones, causing the balance to appear to periodically plateau. – Michael - sqlbot Jun 21 '16 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.