Hands-On Lab945 words

Hands-On Lab: Optimizing AWS Resource Performance and Costs

Unit 7: Performance and Cost Optimization

Hands-On Lab: Optimizing AWS Resource Performance and Costs

This lab provides a guided experience in identifying performance bottlenecks and cost inefficiencies within an AWS environment. You will act as a CloudOps Engineer tasked with rightsizing compute resources, optimizing storage performance, and implementing cost controls using AWS native tools.

[!WARNING] Remember to run the teardown commands at the end of this lab to avoid ongoing charges for provisioned resources.


Prerequisites

  • AWS Account: An active AWS account with AdministratorAccess or equivalent IAM permissions.
  • CLI Tools: AWS CLI installed and configured with a profile. Run aws configure to set up your credentials.
  • Resources: Ensure you have at least one running EC2 instance (e.g., t3.micro) with an attached EBS volume to perform modifications. If you don't, create one before starting Step 2.
  • Knowledge: Basic understanding of EC2, EBS, and IAM.

Learning Objectives

By the end of this lab, you will be able to:

  1. Analyze rightsizing recommendations using AWS Compute Optimizer.
  2. Optimize EBS volume performance and cost using the AWS CLI and Console.
  3. Implement proactive cost monitoring using AWS Budgets.
  4. Analyze spend patterns using AWS Cost Explorer.

Architecture Overview

This lab interacts with the following AWS services to create a feedback loop between monitoring, analysis, and remediation.

Loading Diagram...

The Optimization Lifecycle

Compiling TikZ diagram…
Running TeX engine…
This may take a few seconds

Step-by-Step Instructions

Step 1: Analyze Compute Optimization Recommendations

Before modifying resources, we must identify which ones are over-provisioned (wasting money) or under-provisioned (hurting performance).

bash
# List EC2 instance recommendations from Compute Optimizer aws compute-optimizer get-ec2-instance-recommendations --region <YOUR_REGION>

[!NOTE] Compute Optimizer requires at least 30 hours of CloudWatch metric data to generate meaningful recommendations. If your account is brand new, the output may be empty.

Console alternative
  1. Log in to the AWS Management Console.
  2. Search for and select AWS Compute Optimizer.
  3. Click EC2 instances in the left sidebar.
  4. Review the "Finding" column for statuses like Over-provisioned or Under-provisioned.

📸 Screenshot: Look for the finding classification and the recommended instance types.

Step 2: Optimize EBS Volume Performance

In this step, we will modify an existing General Purpose SSD (gp2) volume to the newer (gp3) type, which often provides better performance at a lower cost.

bash
# Find your volume ID aws ec2 describe-volumes --query "Volumes[*].{ID:VolumeId,Type:VolumeType}" --output table # Modify the volume to gp3 aws ec2 modify-volume --volume-id <YOUR_VOLUME_ID> --volume-type gp3

[!TIP] gp3 volumes allow you to provision IOPS and Throughput independently of storage size, unlike gp2.

Console alternative
  1. Navigate to EC2 > Volumes.
  2. Select your volume.
  3. Select Actions > Modify volume.
  4. Change Volume Type to gp3.
  5. Click Modify and confirm.

Step 3: Configure a Monthly Cost Budget

To prevent surprise bills, we will set a budget that alerts us if our monthly spend exceeds $10.

bash
# Note: This requires a budget definition JSON file. # For this lab, we will use the Console as the CLI syntax for Budgets is highly complex.
Console Instructions
  1. Search for AWS Budgets.
  2. Click Create budget.
  3. Choose Cost budget (Recommended).
  4. Set the Budget name to Monthly-Lab-Limit.
  5. Set Budget amount to $10.00.
  6. Under Alerting, add an alert at 80% of the budget ($8.00) and enter your email address.
  7. Click Create budget.

Checkpoints

  • Compute Optimizer: Did you see any instances listed? (If not, why? Hint: Metric duration).
  • EBS State: Run aws ec2 describe-volumes --volume-ids <ID> and verify the State is modifying or in-use and type is gp3.
  • Budget Status: Does your budget show in the AWS Budgets dashboard with a green status?

Troubleshooting

ProblemPotential CauseFix
AccessDenied when running CLIInsufficient IAM permissionsAttach the AdministratorAccess policy or specific service policies (EC2, Budgets).
Volume modification failsVolume is currently being modifiedWait for the previous modify-volume task to reach 100% or completed state.
No data in Cost ExplorerNew AccountCost Explorer data takes up to 24 hours to populate after enabling.

Clean-Up / Teardown

To ensure no additional costs are incurred, delete the resources used during this lab.

  1. Delete Budget:
    bash
    # CLI deletion requires Account ID aws budgets delete-budget --account-id <YOUR_ACCOUNT_ID> --budget-name Monthly-Lab-Limit
  2. Terminate EC2 Instances: If you created a test instance, terminate it now.
    bash
    aws ec2 terminate-instances --instance-ids <YOUR_INSTANCE_ID>
  3. Delete Volumes: If you have unattached EBS volumes, delete them to save costs.

Cost Estimate

  • EC2 (t3.micro): ~$0.0104/hour (Free Tier eligible).
  • EBS (gp3): $0.08/GB-month (Free Tier eligible up to 30GB).
  • AWS Budgets: First 2 budgets are free.
  • Compute Optimizer: Free for standard EC2 metrics.

Total Lab Cost: Typically $0.00 if within Free Tier limits, otherwise < $0.10.


Concept Review

ServicePrimary Use in Optimization
Compute OptimizerRightsizing recommendations based on historical usage.
Cost ExplorerVisualizing spend trends and identifying anomalies.
AWS BudgetsProactive alerting based on defined spend thresholds.
gp3 VolumesDecoupling performance (IOPS) from capacity (GB) to reduce waste.

Ready to study AWS Certified CloudOps Engineer - Associate (SOA-C03)?

Practice tests, flashcards, and all study notes — free, no sign-up needed.

Start Studying — Free