CPU Credits
CPU Credits are a key feature of AWS EC2 T2 and T3 instance types, enabling these instances to handle variable workloads efficiently by allowing bursts of CPU performance when needed.
- Usage: CPU Credits are utilized when instances need to exceed their baseline performance level temporarily.
- Earning Credits: Instances earn CPU Credits when they operate below their baseline performance. This allows them to accumulate credits for future use.
- Consuming Credits: When an instance bursts above its baseline CPU performance, it consumes these credits. Each credit allows one virtual CPU (vCPU) to run at 100% utilization for one minute.
- Storage Duration: Accumulated credits can be stored for up to 7 days. After this period, any unused credits are lost.
- Unlimited Mode: T3 instances can operate in Unlimited Mode, which allows them to burst beyond their available CPU credits. However, this can lead to additional costs if the instance consistently runs above its baseline level, as the user is charged for the extra CPU credits consumed during these bursts.
In summary, CPU Credits provide a flexible and cost-effective way for T2 and T3 instances to manage workloads that require occasional bursts of performance while also allowing for cost savings when baseline usage is maintained.
Example of CPU Credits
Scenario: Suppose you have a T3 instance (e.g., t3.medium) running a web application with fluctuating traffic patterns.
- Baseline Performance: The t3.medium instance has a baseline performance of 20% CPU utilization. This means it can use the CPU at this level without consuming any CPU credits.
- Traffic Patterns:
- Normal Operation: During regular hours, the application runs at an average of 15% CPU utilization. Since it’s below the baseline, the instance earns CPU Credits.
- Peak Traffic: At peak hours (e.g., during a sale event), CPU usage spikes to 60% for several minutes. This exceeds the baseline performance, so the instance starts consuming its accumulated CPU credits.
- Credit Accumulation:
- Suppose the instance runs at 15% CPU for 10 hours (600 minutes).
- During this time, it earns 600 CPU credits (since it operates below its baseline).
- If during peak traffic the instance runs at 60% CPU for 30 minutes, it consumes 30 CPU credits to support the extra CPU usage above the baseline.
- Credit Usage:
- After the peak, the instance resumes back to its normal usage of 15%.
- Over the next 10 hours, it continues to earn more credits. Now it has 570 credits remaining after using 30 credits during the peak traffic.
- Unlimited Mode:
- If the traffic continues to stay high, you can enable Unlimited Mode for the instance.
- In this mode, if the instance runs out of credits, it can still burst beyond its baseline, but you will be charged extra for any additional CPU credits consumed beyond the baseline performance.
Summary:
In this example, the T3 instance effectively manages its workload using CPU Credits, allowing it to handle increased traffic without downtime while maintaining cost efficiency. By monitoring usage and credits, you can ensure optimal performance during peak times while avoiding unnecessary costs during regular operation.
Reference:
Burstable performance instances - Amazon Elastic Compute Cloud