dissected.io
Lesson 21 of 23
Advancedadvancedfinopscost-optimizationrightsizingsavings-plans11 min read

Cloud Cost Optimization

The billing fundamentals lesson covered how cloud pricing works. This lesson covers strategy — how to systematically reduce cloud spend without damaging reliability or developer velocity. Cost optimization is an ongoing practice, not a one-time project, and the biggest savings come from architectural decisions, not from haggling over instance sizes.

Cloud Cost Optimization -- Where the Money Actually Goes

Monthly Cost Breakdown

Total: $10,800/mo

EC2 Compute
$3,200
Idle GPU (p3)
$2,400
Orphan EBS
$800
NAT Gateway
$1,800
Data Transfer
$2,200
S3 Storage
$400

Optimization Hierarchy

1. Eliminate idle

GPU + orphan volumes removed

2. Rightsize

Instances fit actual utilization

3. Commit baseline

Discount on steady usage

4. Spot for batch

Interruptible workloads

5. Architect

CDN absorbs egress, VPC endpoints

Where Savings Actually Came From

Before

30%
22%
17%
20%

$10,800

After

61%
12%
17%
10%

$3,450

Counterintuitive

Compute (what engineers focus on) shrank modestly. Idle resources, egress, and NAT (what they ignore) were the majority of savings.

Over-Commitment

Committed 100% of usage

Usage Drops 40%

Paying for unused capacity

Reserved Instances

Manual 1/3-yr commitment

Savings: $7,350/mo (68%). Most came from what engineers don't watch.

The FinOps Loop

FinOps (cloud financial operations) is a practice, not a tool. It follows a continuous loop: Inform — know what you're spending and who's spending it. Optimize — act on that data to reduce waste. Operate — establish governance to prevent waste from recurring. Most organizations stall at "inform" because visibility alone feels productive. It isn't. The loop only works if you actually change things.

Visibility First

You can't optimize what you can't see. The foundation is tagging and labeling — every resource gets tags for team, environment, service, and cost center. Untagged resources are invisible waste. Enforce tagging through policy (AWS Tag Policies, GCP Org Policies, Azure Policy) and make untagged resources a compliance violation.

Showback reports costs to teams so they see the impact of their decisions. Chargeback actually bills teams internally. Showback changes behavior; chargeback changes it faster. The real goal is unit economics — cost per customer, cost per transaction, cost per feature. Aggregate cloud spend is meaningless; cost relative to business value is actionable.

The Optimization Hierarchy

Think of cost optimization as a priority stack. Work from the top down — each level is higher-impact and lower-effort than the next.

1. Eliminate

The cheapest resource is the one that doesn't exist. Look for: idle resources — load balancers with no targets, EC2 instances at 2% CPU for the past month, dev environments running 24/7 when engineers work 8 hours a day. Orphaned volumes — EBS volumes detached from any instance, still costing money. Forgotten environments — that staging stack from the project that shipped six months ago. Every organization has thousands of dollars per month in resources nobody is using.

2. Rightsize

Most instances are 2-4x over-provisioned. Engineers pick large instance types during development ("just in case"), and nobody ever sizes them down. Use AWS Compute Optimizer, GCP Recommender, or Azure Advisor — they analyze actual utilization and recommend smaller sizes. A m5.xlarge running at 15% CPU should be a m5.large or smaller. This is free money.

Rightsizing databases is even more impactful. An RDS instance running at 10% CPU with 200GB provisioned IOPS that you don't need is burning money constantly. Check actual performance metrics before resizing, but check them.

3. Commit

Once you know your baseline, commit to it. Reserved Instances (AWS, Azure) and Committed Use Discounts (GCP) offer 30-60% savings over on-demand pricing in exchange for 1-3 year commitments. Savings Plans (AWS) are more flexible — they commit to a dollar amount of compute per hour rather than specific instance types.

The key difference: GCP applies sustained use discounts automatically — if you run an instance for more than 25% of the month, you start getting discounts, up to 30% for full-month usage. No commitment required. AWS and Azure require explicit commitments. GCP's approach is more forgiving for variable workloads; AWS's approach rewards deliberate capacity planning.

4. Spot and Preemptible

Spot instances (AWS), preemptible/spot VMs (GCP), and spot VMs (Azure) offer 60-90% savings for workloads that can tolerate interruption. The provider can reclaim these instances with little notice (2 minutes on AWS, 30 seconds on GCP). Use them for: batch processing, CI/CD builds, stateless web tier behind auto-scaling groups that can absorb instance loss, and distributed computation (Spark, training jobs).

Don't use spot for: databases, single-instance applications, or anything where instance termination causes data loss.

5. Architect

The deepest savings come from architectural decisions. Scale to zero — serverless functions, Cloud Run, and Fargate with scale-to-zero configurations don't cost anything when idle. Dev environments that scale to zero on nights and weekends can cut their cost by 65%.

Caching reduces both compute and database costs. A $50/month Redis instance that caches your most-frequent database queries can save $500/month in database sizing.

Keep traffic in-AZ — cross-AZ data transfer costs money (1-2 cents per GB on AWS). If your web server in AZ-a talks to your database in AZ-b for every request, that adds up. AZ-aware routing keeps traffic local when possible.

Managed vs self-managed TCO — running your own Kafka cluster on EC2 looks cheaper than MSK until you count the engineering time for patching, monitoring, scaling, and incident response. Sometimes the managed service is genuinely cheaper; sometimes it isn't. Do the actual math.

The Egress and NAT Deep Dive

Data transfer costs are cloud's hidden tax, and they can dominate your bill if you're not careful.

Cross-AZ data transfer on AWS costs $0.01/GB in each direction. A chatty microservice architecture doing 10TB/month of cross-AZ traffic costs $200/month in data transfer alone. Multiply that by every service pair. GCP charges the same; Azure charges less for cross-AZ but more for cross-region.

NAT Gateway data processing on AWS is $0.045/GB — separate from the data transfer charge. If your private subnets pull container images, package updates, or API calls through a NAT Gateway, you're paying nearly 5 cents per gigabyte. At scale, this is brutal. Mitigations: use VPC endpoints for AWS services (S3, ECR, DynamoDB), cache container images in ECR, and use interface endpoints for frequently called APIs.

CDN offload moves traffic to the edge, where egress is cheaper. CloudFront egress is less than half the cost of direct EC2 egress in most regions. Serving static assets through a CDN isn't just a performance optimization — it's a cost optimization.

VPC endpoints keep traffic between your VPC and AWS services on the AWS network, avoiding NAT Gateway costs entirely. A gateway endpoint for S3 is free. Interface endpoints cost $0.01/hour plus $0.01/GB, but that's still cheaper than NAT Gateway processing for high-volume services.

AWS Implementation

AWS cost tools: Cost Explorer for analysis and forecasting, Budgets for alerts, Compute Optimizer for rightsizing, Savings Plans and Reserved Instances for commitments, Trusted Advisor for waste detection, Cost Anomaly Detection for unexpected spikes.

GCP Implementation

GCP cost tools: Billing Reports and BigQuery billing export for analysis, Budgets and Alerts, Recommender for rightsizing and idle resources, Committed Use Discounts and automatic sustained use discounts, Active Assist recommendations. GCP's billing export to BigQuery is a standout feature — it lets you write arbitrary SQL queries against your cost data.

Azure Implementation

Azure cost tools: Cost Management + Billing for analysis, Budgets and Alerts, Azure Advisor for rightsizing, Reservations and Savings Plans for commitments, Cost Analysis with custom views. Azure's integration with Microsoft 365 licensing can create hybrid cost optimizations that AWS and GCP can't match.

Side-by-Side Comparison

AspectAWSGCPAzure
Cost analysisCost ExplorerBilling Reports / BigQuery exportCost Management
RightsizingCompute OptimizerRecommenderAzure Advisor
Commitment discountsSavings Plans / RIs (30-60%)CUDs + auto sustained use (20-57%)Reservations / Savings Plans
Spot savingsUp to 90%Up to 91%Up to 90%
Cross-AZ transfer cost$0.01/GB each direction$0.01/GBGenerally lower
NAT data processing$0.045/GB$0.045/GBPer-GB pricing varies

Anti-Patterns

Optimizing engineer time to save $200/month. If a senior engineer spends a week migrating a service to save $200/month, the ROI is negative for two years. Focus on the big items. Sort your bill by line item and work top-down.

Cost-cutting that damages reliability. Removing redundancy, reducing instance sizes below safe thresholds, or eliminating monitoring to save money will cost you far more in downtime than you saved. Reliability has a dollar value — an hour of downtime might cost more than a year of that "wasted" standby capacity.

Key Takeaways

  • Follow the FinOps loop (inform, optimize, operate) and track unit economics — cost per customer or per transaction, not just total spend
  • Work the optimization hierarchy top-down: eliminate idle resources, rightsize (most instances are 2-4x over-provisioned), commit to discounts, use spot for fault-tolerant work, then architect for efficiency
  • Data transfer and NAT Gateway costs are cloud's hidden tax — use VPC endpoints, CDN offload, and AZ-aware routing to control them
  • GCP applies sustained use discounts automatically; AWS and Azure require explicit commitments — factor this into your cloud comparison
  • Tagging is the foundation of cost visibility; untagged resources are invisible waste
  • Never optimize cost at the expense of reliability — the math on downtime cost almost always wins

Next, we'll look at hybrid and multi-cloud architectures — and why the marketing rarely matches reality.

Enjoyed this breakdown?

Get new lessons in your inbox.