Part of Datorkirurgen AB – IT experts across Sweden

CPU credits control performance on t3 instances in AWS. This is how we read the credit balance, set sensible alerts in CloudWatch and choose the right mode for your server.

How a burstable instance works

AWS calls the instances in the t3 family burstable. They have a baseline of processor power, and above it they can temporarily use more. For this, they use CPU credits. When the server stays below the baseline, it earns credits, and when it goes above, it spends them. The model is intended for web servers that have a low load most of the day but short peaks.

The problem arises when the credits run out. In standard mode, the server then slows down to the baseline, which for a smaller instance is only a fraction of a processor core. The websites become slow, SSH sluggish and everything seems wrong. In unlimited mode, however, the server continues at full speed, but then the surplus costs extra. Therefore, it is important to understand which mode the server has and what the balance looks like.

Many discover the problem only when clients complain about a slow website. The server seems healthy in the console, since it responds and shows no faults. Only when you look at the credit balance do you see that it has been at zero for several hours. Therefore, we always add the balance to the same overview as other metrics. Then the link between slow pages and empty credits becomes clear.

CPU credits in standard mode compared with unlimited on t3 instances
CPU credits in standard mode compared with unlimited on t3 instances. This is how Linux Service, part of Datorkirurgen AB, works for businesses in Vasastan and Norrmalm.

An alert that went off all the time

When we took over monitoring of a server, there was already an alert in CloudWatch. It was set to go off when processor usage was 0.99 per cent or more for five minutes. The screenshot shows the result: the alert stayed In alarm almost all the time. Such an alert is worse than none, since everyone eventually stops looking at it. Then you miss the alerts that actually mean something.

The cause was probably a typo, where someone meant 99 per cent but wrote 0.99. It is a common mistake, since you specify the value as a percentage and not as a fraction. Therefore, we changed the limit to a sensible value and added an alert for the credit balance. The latter is the most important for a t3 instance.

A CloudWatch alert with the limit 0.99 per cent that stays in alarm almost all the time
A CloudWatch alert with the limit 0.99 per cent that stays in alarm almost all the time. A real screenshot from the AWS console. The instance ID is masked.
CPU credits and alarm history in CloudWatch, where the alert alternates between OK and In alarm
CPU credits and alarm history in CloudWatch, where the alert alternates between OK and In alarm. An example from our work for clients in Uppsala.

The right alerts for a t3 instance

For a t3 instance, we set two alerts. The first concerns processor usage, for example above 80 per cent for fifteen minutes. Such an alert catches real problems, such as a process that has hung or an attack. The second concerns the CPUCreditBalance metric. When the balance falls below a certain level, we receive a warning before the server slows down. As a result, we have time to act.

In addition, we add alerts for memory and disk via the CloudWatch agent, since AWS does not measure them from the start. All alerts go to email or text message via SNS. We test every alert by temporarily lowering the limit, and after that we reset it. In fact, nobody knows whether an alert that has never been tested works. We also document who receives the alerts and what the recipient should do.

Processor usage in CloudWatch with the limit line that was far too low
Processor usage in CloudWatch with the limit line that was far too low. Linux Service, part of Datorkirurgen AB, helps businesses in Täby, Danderyd and Lidingö with servers, scripts and databases.
An alert for the CPU credit balance created with the AWS CLI
An alert for the CPU credit balance created with the AWS CLI. This is how Linux Service, part of Datorkirurgen AB, works for businesses in Nacka and Södermalm.

Standard, unlimited or a larger instance?

The choice of mode depends on how you use the server. If the load is low with short peaks, standard mode is enough, and it gives the lowest cost. If the peaks are important, for example during a campaign, unlimited can be right. However, you should then follow the cost closely. If the server stays above the baseline almost all the time, a larger instance or another family is often cheaper.

We analyse statistics for the last few weeks before we propose anything. They show both averages and peaks, as well as how the credit balance has moved. Sometimes the analysis shows that a single process uses more than it should. In that case, we fix it instead of buying more power. Feel free to also read about disk space, journald and swap, which also affect how the server is doing.

Contact Linux Service about CPU credits

Linux Service is part of Datorkirurgen AB and operates servers on AWS every day. We set up alerts that mean something, analyse CPU credits and choose the right instance for your load. AWS describes the model in its documentation on burstable instances.

Therefore, contact us if your server becomes slow at certain times or if the alerts go off all the time. We carry out a review and propose actions. We work remotely. Moreover, we can take over the monitoring completely.

Frequently asked questions about CPU credits

Questions about CPU credits

CPU credits and alerts in CloudWatch

More about choosing an instance

Website developed by Datorkirurgen AB · Privacy policy