Updated on 2024-07-31 GMT+08:00

CPU Credits

Concept

CPU credits measure computing, storage, and network resource usage of an ECS. ECSs use CPU credits to ensure baseline performance, preventing issues caused by CPU overcommitment.

CPU-credit-based ECSs are suitable for the applications requiring baseline level of vCPU performance generally and burstable performance in case of traffic bursts.

General computing-basic ECSs run based on CPU credits (do not incur additional costs). For more details, see General Computing-Basic ECSs.

Working Rules

After a CPU-credit-based ECS is created, the cloud platform automatically allocates initial CPU credits to the ECS for its burstable performance.

After the ECS runs, its credits are accrued or spent. When the actual computing performance of the ECS is higher than the baseline CPU performance, the CPU credits are spent to meet the performance requirements. When the actual computing performance is lower than the baseline CPU performance, the CPU credits are accrued until the CPU credit balance limit is reached.

  • CPU credits can be accrued. However, after the credits reach the CPU credit balance limit, any new credits that are earned will be discarded.
  • Initial credits are not counted in the CPU credit balance limit.
  • When an ECS starts to spend CPU credits, it preferentially uses the initial CPU credits.
  • One CPU credit is equal to one vCPU running at 100% usage for one minute.
  • When the actual computing performance is higher than the baseline performance, the accrued credits are spent until they are used up. Then, the actual computing performance cannot exceed the baseline performance.

Related Terms

Table 1 Terms related to CPU credits (taking a T6 ECS as an example)

Term

Description

Example

Initial CPU credits

After a T6 ECS is created, the cloud platform automatically allocates CPU credits to this ECS. These credits are initial CPU credits. Initial CPU credits are allocated only after an ECS is created.

After a t6.large.1 is created, it has 60 initial CPU credits.

CPU credit balance limit

When the actual computing performance is lower than the baseline CPU performance, the CPU credits are accrued. The accrued credits will not expire on a running ECS. When the credits reach the maximum value allowed, which is specified by the CPU credit balance limit, any new credits that are earned will be discarded. The CPU credit balance limit varies depending on ECS flavors.

The CPU credit balance limit for a t6.large.1 ECS is 576. When its accrued CPU credits reach 576, no more credits will be accrued. When its accrued CPU credits are smaller than 576, the CPU credits can be accrued again.

CPU credit earn rate (credits/hour)

The number of CPU credits earned by an ECS per hour, which corresponds to CPU baseline.

One CPU credit is equal to one vCPU running at 100% usage for one minute.

The CPU credit earn rate of a t6.large.1 ECS is 24, indicating that a t6.large.1 ECS can earn 24 CPU credits per hour.

CPU baseline (%)

When the number of CPU credits that an ECS spends per minute is the same as the number of CPU credits that the ECS earns per minute, the ECS runs at the CPU baseline.

The CPU baseline of a t6.large.1 ECS is 40%. When the actual computing performance of a t6.large.1 ECS reaches 40%, the number of credits spent by the ECS per minute is the same as the number of credits earned by the ECS per minute.

Average CPU baseline (%)

When an ECS runs at CPU baseline, the computing performance of each vCPU is the average CPU baseline, which is calculated using the following formula:

Average CPU baseline = CPU baseline/Number of vCPUs

The CPU baseline of a t6.large.1 ECS is 40%, and the ECS has two vCPUs. Then, the average CPU baseline is 20%.

Spent CPU credits

When the actual computing performance of an ECS is higher than the baseline CPU performance, the CPU credits are spent to meet the performance requirements.

One CPU credit is spent for one vCPU running at 100% usage for one minute.

The formula for calculating the CPU credits spent per minute is as follows:

Number of CPU credits spent per minute = 1 CPU credit x Actual computing performance

When a t6.large.1 ECS runs at the computing performance of 20% for one minute, the ECS spends 0.2 CPU credits.

Accrued CPU credits

  • When the actual computing performance of an ECS is less than the baseline CPU performance, the number of CPU credits spent per minute is smaller than the number of CPU credits earned per minute. Therefore, the remaining CPU credits are accrued until the CPU credit balance limit is reached.
  • When the actual computing performance is higher than the baseline CPU performance, the number of CPU credits spent per minute is greater than the number of CPU credits earned per minute. In such a case, the ECS spends accrued CPU credits (initial CPU credits preferentially used) to comply with burstable CPU performance.

The formula for calculating the number of CPU credits accrued per minute is as follows:

Number of CPU credits accrued per minute = 1 CPU credit x (CPU baseline – Actual computing performance)

The CPU baseline of a t6.large.1 ECS is 40%. When the actual computing performance of the ECS is 10%, the ECS accrues 0.3 CPU credits per minute.

Impact of CPU Credits After an ECS Is Stopped

The change of CPU credits varies depending on the ECS billing mode and network type.

Table 2 Billing modes and CPU credits

Billing Mode

CPU Credit Change After an ECS Is Stopped

Yearly/Monthly

The existing CPU credits are retained and accrued until the CPU credit balance limit is reached.

Pay-per-use

The existing CPU credits are retained but not accrued.

Spot price

The existing CPU credits are retained but not accrued.