Cost and Performance Optimization¶
AWS Cost Management - Cost optimization tools
AWS Cost Explorer¶
Cost Explorer - Visualize and analyze costs
Key Features¶
- Visualize cost and usage data over time
- Filter by service, account, region, tag, instance type
- Daily or monthly granularity
- Forecasting for future cost estimates
- Reservation and Savings Plan recommendations
Common Reports¶
- Monthly costs by service - identify top spending services
- Daily costs with trend - spot cost anomalies
- Cost by linked account - multi-account cost tracking
- Instance type usage - identify right-sizing opportunities
- Reserved Instance utilization - track RI usage efficiency
Cost Allocation Tags¶
- AWS-generated tags -
aws:createdBy,aws:cloudformation:stack-name - User-defined tags - custom key-value pairs for cost tracking
- Activate tags in Billing console to appear in Cost Explorer
- Use for: department, project, environment, cost center
Cost Allocation Tags - Organize costs with tags
AWS Budgets¶
AWS Budgets - Budget alerts and actions
Budget Types¶
- Cost budget - track spending against a threshold
- Usage budget - track service usage (hours, GB, requests)
- Reservation budget - track RI and Savings Plan utilization
- Savings Plans budget - track Savings Plan coverage
Alerts and Actions¶
- Email and SNS notifications when thresholds are reached
- Configurable thresholds: actual cost, forecasted cost
- Budget Actions - automated responses to budget alerts:
- Apply IAM policy to restrict access
- Apply SCP to restrict account actions
- Stop EC2 or RDS instances
Best Practices¶
- Set budgets at account and service level
- Configure both actual and forecasted alerts
- Set alerts at 50%, 75%, 90%, and 100% thresholds
- Use budget actions for automated cost control
AWS Trusted Advisor¶
Trusted Advisor - Best practice recommendations
Check Categories¶
- Cost Optimization - idle resources, underutilized instances, unused EIPs
- Performance - high utilization instances, CloudFront optimization
- Security - open security groups, IAM use, MFA on root
- Fault Tolerance - Multi-AZ, backup, replication
- Service Limits - approaching service quotas
Access Levels¶
- Basic/Developer support - 7 core security checks (limited)
- Business/Enterprise support - all checks available
- API access - programmatic access to check results
Key Checks for Operations¶
- Underutilized EC2 instances
- Idle load balancers
- Unassociated Elastic IP addresses
- Amazon RDS idle DB instances
- Low utilization Amazon EBS volumes
- Security groups with unrestricted access (0.0.0.0/0)
- Service limits approaching threshold
AWS Compute Optimizer¶
Compute Optimizer - Right-sizing recommendations
Supported Resources¶
- EC2 instances
- Auto Scaling Groups
- EBS volumes
- Lambda functions
- ECS services on Fargate
How It Works¶
- Analyzes CloudWatch metrics (CPU, memory, network, disk)
- Uses ML to identify optimal resource configurations
- Provides recommendations with estimated savings
- Risk levels: Very Low, Low, Medium, High
Recommendation Types¶
- Over-provisioned - reduce instance size for cost savings
- Under-provisioned - increase instance size for performance
- Optimized - current configuration is appropriate
- Not optimized - change instance family for better fit
Reserved Instances and Savings Plans¶
Reserved Instances¶
Reserved Instances - Capacity reservations
Standard RIs: - Up to 72% discount vs On-Demand - 1-year or 3-year term - Payment options: All Upfront, Partial Upfront, No Upfront - Can modify AZ, instance size (within family), network type - Cannot change instance family, OS, or tenancy
Convertible RIs: - Up to 66% discount vs On-Demand - Can change instance family, OS, tenancy - Must exchange for equal or greater value - 1-year or 3-year term
Savings Plans¶
Savings Plans - Flexible pricing
Compute Savings Plans: - Up to 66% discount - Applies to any EC2, Fargate, or Lambda usage - Any instance family, region, OS, or tenancy - Most flexible option
EC2 Instance Savings Plans: - Up to 72% discount - Specific instance family and region - Flexible on size, OS, and tenancy - Best discount for predictable EC2 usage
Spot Instances¶
Spot Instances - Spare capacity pricing
- Up to 90% discount vs On-Demand
- Can be interrupted with 2-minute warning
- Best for: batch processing, data analysis, CI/CD, testing
- Use Spot Fleet for diversification across instance types and AZs
- Not suitable for: databases, stateful applications, production web servers
Performance Optimization¶
EC2 Performance¶
Right-Sizing: - Use Compute Optimizer recommendations - Monitor CloudWatch metrics for utilization patterns - Consider burstable instances (T3/T4g) for variable workloads - Test with different instance families before committing
Enhanced Networking: - Elastic Network Adapter (ENA) - up to 100 Gbps - Elastic Fabric Adapter (EFA) - HPC workloads - Placement groups for low-latency communication - EBS-optimized instances for dedicated storage bandwidth
Enhanced Networking - High performance networking
EBS Performance¶
Volume Types: - gp3 - general purpose SSD, 3000 IOPS baseline, up to 16,000 - gp2 - general purpose SSD, burst performance based on size - io2 Block Express - highest performance, up to 256,000 IOPS - st1 - throughput optimized HDD, sequential reads - sc1 - cold HDD, infrequent access
Optimization Tips: - Use gp3 instead of gp2 for cost savings with predictable IOPS - Pre-warm volumes restored from snapshots (first read penalty) - Enable EBS-optimized on supported instances - Monitor VolumeQueueLength for I/O bottlenecks
Database Performance¶
RDS Proxy: - Connection pooling for RDS and Aurora - Reduces database connection overhead - Improves failover times (60% faster) - Supports IAM authentication
RDS Proxy - Database connection management
DynamoDB DAX: - In-memory cache for DynamoDB - Microsecond read latency - Write-through caching - Compatible with DynamoDB API
DynamoDB DAX - In-memory acceleration
Aurora Serverless v2: - Auto-scaling database capacity - Scales in increments of 0.5 ACU - Minimum and maximum ACU settings - Scales to zero with Aurora Serverless v2 (with limitations)
Aurora Serverless v2 - Auto-scaling database
Read Replicas: - Offload read traffic from primary database - Up to 5 read replicas for RDS, 15 for Aurora - Cross-region read replicas for global performance - Can be promoted to standalone database
Caching Strategies¶
ElastiCache: - Redis - complex data types, persistence, pub/sub, replication - Memcached - simple caching, multi-threaded, no persistence - Lazy loading: load data into cache on cache miss - Write-through: write to cache when writing to database - TTL: set expiration to prevent stale data
CloudFront Performance¶
- Cache static and dynamic content at edge locations
- Custom cache policies for different content types
- Origin Shield for reducing origin load
- Compress content for faster delivery
Cost Optimization Strategies¶
Quick Wins¶
- Delete unattached EBS volumes
- Release unused Elastic IPs
- Terminate idle instances
- Clean up old snapshots
- Review and delete unused security groups and load balancers
Medium-Term Strategies¶
- Right-size instances based on utilization data
- Purchase Reserved Instances or Savings Plans for steady-state
- Use Spot Instances for fault-tolerant workloads
- Implement S3 lifecycle policies for storage tiering
- Use VPC endpoints to reduce NAT Gateway costs
Long-Term Architecture¶
- Adopt serverless where appropriate (Lambda, Fargate, Aurora Serverless)
- Design for auto-scaling to match demand
- Implement data lifecycle management
- Use multi-tier storage strategies
- Consolidate accounts with Organizations for volume discounts
Key Takeaways¶
- Cost Explorer - primary tool for cost analysis and forecasting
- Budgets - set alerts and automated actions on spending thresholds
- Trusted Advisor - best practice checks (full access requires Business support)
- Compute Optimizer - ML-based right-sizing recommendations
- Right-size first - before committing to Reserved Instances
- Savings Plans - more flexible than Reserved Instances for most use cases
- Spot Instances - up to 90% savings for fault-tolerant workloads
- Caching - ElastiCache, DAX, and CloudFront reduce load and improve performance