When planning to downsize an Amazon Elastic Compute Cloud (EC2) instance, it is essential to assess not only CPU and memory usage but also the performance limits of the Amazon Elastic Block Store (EBS) associated with the instance. Smaller EBS-optimized instance types typically have lower performance baselines and depend on burst credits to manage peak workloads. If the I/O demands of a workload deplete these credits faster than they can be replenished, the instance will throttle performance to its baseline level.
Understanding Burst Credits
Burstable EBS-optimized instances maintain a credit pool for both IOPS and throughput. The pool is designed to allow for bursts of performance above the baseline, but it can become depleted if usage consistently exceeds the baseline. AWS resets this pool every 24 hours, ensuring that instances have a minimum of 30 minutes of burst capacity daily.
Gathering Metrics from CloudWatch
To simulate burst credit behavior, teams can pull EBS metrics from Amazon CloudWatch. This involves:
- Ensuring the AWS account has permissions for
cloudwatch:GetMetricDataandec2:DescribeInstanceTypes. - Collecting metrics at 5-minute intervals for a minimum of two weeks to capture accurate workload patterns.
- Using the
AWS/EC2namespace to retrieve necessary metrics, including maximum I/O rates and minimum balance percentages.
Simulating Credit Balance
With the gathered metrics, users can simulate the credit balance for the target instance type. This involves:
- Accumulating credits when actual usage is below the baseline.
- Draining credits when usage exceeds the baseline.
- Resetting the credit pool at the start of each day to model AWS's daily reset policy.
Analyzing Simulation Results
The simulation will yield two key outputs for each budget: the lowest credit balance during the observation period and the number of intervals where the balance reached zero. These results help determine whether the workload can sustain performance on the smaller instance type.
Key Takeaways
Before downsizing an EC2 instance, it is vital to:
- Evaluate EBS burst credit limits alongside CPU and memory usage.
- Utilize Amazon CloudWatch to gather and analyze performance metrics.
- Simulate the credit balance to forecast potential throttling issues.
Next Steps
For those looking to run this analysis, a sample Python script is available to automate the data retrieval and simulation process. Additionally, reviewing the documentation on EBS-optimized instances can provide further insights into baseline and burst limits.