Security, Cost & Well-Architected Frameworks

Cost Optimization Strategies

4 min read

Cost optimization is a key differentiator for cloud architects. Interviewers expect you to balance performance, reliability, and cost effectively.

AWS Pricing Models

Compute Pricing Options

ModelDiscountCommitmentBest For
On-Demand0%NoneVariable workloads
Savings PlansUp to 72%1-3 yearsPredictable compute
Reserved InstancesUp to 72%1-3 yearsSpecific instances
Spot InstancesUp to 90%NoneFault-tolerant workloads

Savings Plans vs Reserved Instances

AspectSavings PlansReserved Instances
FlexibilityAny instance familySpecific instance type
RegionRegion-flexible (Compute SP)Region-specific
ServiceEC2, Lambda, FargateEC2, RDS only
ManagementSimplerMore complex
RecommendationModern choiceLegacy workloads

Interview Question: Cost Strategy

Q: "Design a cost optimization strategy for a variable workload with a predictable baseline."

A: Hybrid approach:

Workload Analysis:
├── Baseline: 100 instances (consistent)
├── Peak: 300 instances (variable)
└── Fault-tolerant batch: 50 instances

Cost Strategy:
├── Baseline (100): Compute Savings Plan (3-year)
│   └── 66% savings
├── Variable (0-200): On-Demand + Spot mix
│   ├── Critical: On-Demand
│   └── Non-critical: Spot (70/30 mix)
└── Batch (50): Spot Instances
    └── Up to 90% savings

Expected Savings: 45-55% compared to all On-Demand.

Right-Sizing

Analysis Process

  1. Collect Metrics (2-4 weeks minimum)

    • CPU utilization
    • Memory usage
    • Network throughput
    • Storage IOPS
  2. Identify Candidates

    • Average CPU < 40%: Downsize
    • CPU consistently > 80%: Upsize
    • Memory-bound: Consider memory-optimized
  3. Test and Validate

    • Load test new size
    • Monitor for 1-2 weeks
    • Rollback plan ready

AWS Tools for Right-Sizing

ToolFunctionCost
Cost ExplorerRight-sizing recommendationsFree
Compute OptimizerML-based recommendationsFree (basic)
Trusted AdvisorInstance recommendationsBusiness/Enterprise

Interview Question: Right-Sizing RDS

Q: "Your RDS database is consistently at 20% CPU. What's your recommendation?"

A: Don't immediately downsize. Analyze holistically:

  1. Check Memory Pressure

    • Low CPU doesn't mean oversized
    • Database may be memory-bound
  2. Analyze Query Patterns

    • Peak vs average utilization
    • Batch job timing
  3. Consider Buffer Pool

    • Larger instance = more cache
    • May improve performance significantly
  4. Recommendation

    • If memory and IOPS also low: Downsize
    • If memory high: Stay or switch to memory-optimized
    • Test thoroughly before production change

Storage Optimization

S3 Storage Classes

ClassAccess PatternCost (per GB)Retrieval
StandardFrequent$$$Instant
Intelligent-TieringVariable$$$ + monitoringInstant
Standard-IAInfrequent (30+ days)$$Instant
One Zone-IAInfrequent, non-critical$Instant
Glacier InstantArchive, instant access$Instant
Glacier FlexibleArchive¢Minutes-hours
Glacier Deep ArchiveLong-term archive¢Hours

S3 Lifecycle Policies

Lifecycle Rules:
  - Transition to Standard-IA: 30 days
  - Transition to Glacier: 90 days
  - Transition to Deep Archive: 365 days
  - Delete: 7 years (compliance)

EBS Optimization

Volume TypeUse CaseCost Consideration
gp3General purpose20% cheaper than gp2
io2High IOPSPay for provisioned IOPS
st1ThroughputCheaper for sequential
sc1Cold storageCheapest block storage

Quick Win: Migrate gp2 to gp3 for immediate 20% savings with same or better performance.

Data Transfer Costs

Transfer Cost Matrix

FromToCost
InternetAWSFree
AWSInternet$0.09/GB (first 10TB)
Same Region (AZ to AZ)$0.01/GB
Cross-Region$0.02/GB
VPC Peering (same region)$0.01/GB
PrivateLink$0.01/GB + hourly

Cost Reduction Strategies

  1. Use VPC Endpoints

    • S3 Gateway endpoint: Free
    • Avoid NAT Gateway data processing
  2. Regional Deployment

    • Keep compute near data
    • Multi-region only when required
  3. CloudFront for Egress

    • Often cheaper than direct egress
    • Additional caching benefits
  4. Compression

    • Compress data before transfer
    • Significant savings for text/logs

Interview Question: Data Transfer

Q: "Your monthly data egress is $50,000. How would you reduce it?"

A: Multi-pronged approach:

StrategyPotential Savings
CloudFront distribution20-40%
Response compression30-50%
Caching headers20-30%
Regional endpoints10-20%
S3 Transfer Acceleration reviewVariable

Action Plan:

  1. Analyze CloudWatch for transfer patterns
  2. Implement CloudFront for repeat requests
  3. Enable gzip/brotli compression
  4. Review API response sizes
  5. Consider reserved capacity for predictable egress

FinOps Practices

Cost Allocation

  1. Tagging Strategy

    • Mandatory: Environment, Owner, Project, CostCenter
    • Enforce via SCP or AWS Config
  2. AWS Organizations

    • Separate accounts by business unit
    • Consolidated billing
    • Reserved capacity sharing

Monitoring and Governance

ToolPurpose
AWS BudgetsAlerts and forecasting
Cost Anomaly DetectionML-based anomaly alerts
Cost ExplorerAnalysis and reporting
Savings Plans recommendationsPurchase guidance

Chargeback Model

Central IT Budget
Cost Allocation Tags
Monthly Reports per Team
Business Unit Chargeback

Key Insight: Cost optimization is continuous, not one-time. Implement automated policies, regular reviews, and team accountability to maintain efficiency as workloads evolve.

Next, we'll explore the AWS Well-Architected Framework. :::

Quick check: how does this lesson land for you?

Quiz

Module 5: Security, Cost & Well-Architected Frameworks

Take Quiz
FREE WEEKLY NEWSLETTER

Stay on the Nerd Track

One email per week — courses, deep dives, tools, and AI experiments.

No spam. Unsubscribe anytime.