Cloud Cost Models and Pricing
Overview
Cloud cost management (FinOps) is the practice of bringing financial accountability to the variable spend model of cloud computing. Understanding the underlying cost models of major providers is the foundation of building cost-efficient, scalable systems.
Core Principle: "Optimize for value, not just cost. Move from 'how much did we spend' to 'how much value did we get for our spend'."
1. Cloud Pricing Fundamentals
Cloud providers typically use a consumption-based model with three primary levers:
- Compute: Charged by time (seconds/hours) and capacity (CPU/RAM).
- Storage: Charged by volume (GB/month), redundancy level, and performance (IOPS).
- Data Transfer: Usually free for "Inbound", charged for "Outbound" (Egress) and sometimes between internal zones/regions.
The Compute Continuum
| Model |
Pricing Metric |
Best For |
Typical Provider Product |
| Virtual Machines |
Unit/Hour or Unit/Second |
Consistent, legacy, or long-running apps |
EC2, GCE, Azure VM |
| Containers |
Resource Requests (CPU/RAM) |
Microservices, dynamic scaling |
Fargate, Cloud Run, ACI |
| Serverless |
Requests + Execution Duration |
Event-driven, intermittent traffic |
Lambda, Cloud Functions |
2. AWS Pricing Model
AWS uses a complex but granular pricing structure.
EC2 (Elastic Compute Cloud)
- On-Demand: Lowest commitment, highest cost. Pay by the second.
- Reserved Instances (RI): Up to 72% discount for 1-3 year commitment. Best for steady-state workloads.
- Savings Plans: Flexible 1-3 year commitment ($/hour) across EC2, Fargate, and Lambda.
- Spot Instances: Up to 90% discount. AWS can reclaim with 2-minute notice. Best for stateless, fault-tolerant apps (CI/CD, batch processing).
S3 (Simple Storage Service)
- S3 Standard: Active data ($0.023/GB).
- S3 Intelligent-Tiering: Auto-moves data based on access patterns ($0.023/GB + monitoring fee).
- S3 Standard-IA: Infrequent access, fast retrieval ($0.0125/GB).
- S3 Glacier Instant Retrieval: Archival data, millisecond retrieval ($0.004/GB).
- S3 Glacier Deep Archive: Long-term storage (7-10 years), 12-hour retrieval ($0.00099/GB).
Lambda
- Requests: $0.20 per 1M requests.
- Duration: Calculated in GB-seconds (Memory allocated × Duration).
- Provisioned Concurrency: Extra fee to keep functions "warm" to avoid cold starts.
RDS (Relational Database Service)
- Instance: Based on type (db.m5.large, etc.).
- Storage: Multi-AZ doubles instance and storage costs.
- I/O: Charged per million I/O requests for some engine types.
Data Transfer Costs
- Ingress (Internet to AWS): Free.
- Egress (AWS to Internet): ~$0.09/GB (first 10TB).
- Inter-AZ: $0.01/GB (both directions).
- Inter-Region: $0.02/GB.
3. GCP Pricing Model
GCP emphasizes simplicity and "Sustained Use Discounts".
Compute Engine
- Standard: Pay-as-you-go.
- Sustained Use Discounts (SUD): Automatic discounts (up to 30%) for running instances for a large portion of the month.
- Committed Use Discounts (CUD): 1 or 3-year commitment for specific vCPU/RAM amounts.
- Preemptible VMs: Equivalent to AWS Spot, but fixed 24-hour max runtime and fixed ~80% discount.
Cloud Storage
- Standard: Hot data.
- Nearline: Data accessed < once/month.
- Coldline: Data accessed < once/quarter.
- Archive: Data accessed < once/year.
BigQuery
- Analysis (On-Demand): $5 per TB scanned.
- Analysis (Capacity/Flat-rate): Reserved slots (vCPUs) for predictable high-volume billing.
- Storage: $0.02/GB (Active), $0.01/GB (Long-term > 90 days).
4. Azure Pricing Model
Virtual Machines
- Pay-as-you-go: Standard rates.
- Reserved Virtual Machine Instances: 1 or 3-year commitment (up to 72% savings).
- Azure Hybrid Benefit: Use existing on-premises Windows Server/SQL Server licenses on Azure to save up to 40%.
Blob Storage
- Hot: Frequently accessed.
- Cool: Stored for 30+ days.
- Archive: Stored for 180+ days.
Functions
- Consumption Plan: Billed based on executions and execution time.
- Premium Plan: Avoids cold starts, allows VNet integration, billed per vCPU and Memory.
5. Hidden Costs (The "Silent Killers")
Many teams blow their budgets on items that aren't the primary compute instances:
- Data Egress: Moving data out of the cloud or between regions is expensive.
- NAT Gateways: AWS charges ~$0.045 per GB processed through a NAT Gateway plus the hourly fee for the gateway itself.
- Load Balancers: LCU (Load Balancer Capacity Units) can scale costs significantly with high connection counts or high throughput.
- Logging & Monitoring: Storing multi-terabyte internal logs in CloudWatch or Datadog can often exceed the cost of the application itself.
- Unused Elastic IPs: AWS charges for IPs that are allocated but not attached to a running instance.
- Snapshots & Backups: Retaining daily snapshots of 10TB volumes indefinitely.
6. Cost Optimization Strategies
The Optimization Pyramid
- Right-Sizing: Ensure instance sizes match actual utilization (CPU < 40% means you should downsize).
- Modernization: Move from VMs to Fargate/Lambda or Graviton (ARM) processors. Graviton typically offers 40% better price-performance.
- Deletions: Clean up "unattached" resources (EBS volumes, EIPs, Load Balancers).
- Purchasing Options: Apply RIs and Savings Plans after right-sizing.
Storage Lifecycle Policy Example (S3)
{
"Rules": [
{
"ID": "MoveToIAAndGlacier",
"Prefix": "logs/",
"Status": "Enabled",
"Transitions": [
{ "Days": 30, "StorageClass": "STANDARD_IA" },
{ "Days": 90, "StorageClass": "GLACIER" }
],
"Expiration": { "Days": 365 }
}
]
}
7. Cost Allocation and Tagging
If you can't measure it, you can't manage it.
Required Tags Hierarchy
- Project:
Project: ProjectPhoenix
- Environment:
Env: Prod, Env: Dev
- Owner:
Owner: TeamAlpha
- Cost Center:
CostCenter: CC-9901
enforcement with Terraform
resource "aws_instance" "example" {
ami = "ami-12345678"
instance_type = "t3.medium"
tags = {
Name = "PhoenixAPI"
Environment = "Prod"
Owner = "TeamAlpha"
CostCenter = "12345"
}
}
8. FinOps Principles (Crawl, Walk, Run)
The FinOps Foundation defines the lifecycle:
- Inform: Visibility into spend. Allocation, tagging, and reporting.
- Optimize: Real-time decision making. Right-sizing and identifying waste.
- Operate: Aligning teams to business goals. Budgets, unit economics, and governance.
| Phase |
Activities |
| Crawl |
Spreadsheet reports, basic tags, monthly reviews. |
| Walk |
Multi-cloud dashboards, automated alerts, RI purchases. |
| Run |
Automated right-sizing, unit-cost tracking, AI-driven anomaly detection. |
9. Tools and Integration
- Native: AWS Cost Explorer, GCP Billing, Azure Cost Management.
- Infrastructure as Code: Infracost (shows cost changes in Pull Requests).
- Kubernetes: Kubecost (allocates cluster costs to namespaces/pods).
- Anomaly detection: AWS Cost Anomaly Detection (Machine Learning based).
10. TCO (Total Cost of Ownership) Calculation
Avoid the "Sticker Price" trap. TCO includes:
- Direct Costs: Server, Storage, Network.
- Indirect Costs: Employee time for patching, DBA time for backups, security compliance.
- Risk Cost: Cost of downtime if self-hosting vs. provider SLA.
TCO Calculation Table (Example: Self-Hosted vs. Managed DB)
| Aspect |
Self-Hosted (EC2) |
Managed (RDS) |
| Instance Cost |
$100/mo |
$140/mo |
| Storage/Backup |
$20/mo |
$30/mo |
| Engineer Hours |
10 hrs ($1000) |
1 hr ($100) |
| Total Cost |
$1120/mo |
$270/mo |
| Winner |
|
✅ RDS |
11. Real Cost Optimization Case Studies
Case Study 1: The "Zombie" Resource Cleanup
- Scenario: A company was spending $50k/month on AWS.
- Discovery: $8k was spent on EBS volumes not attached to any VM.
- Action: Ran a script to find and delete volumes unattached > 14 days.
- Outcome: Immediate $8,000/month (16%) savings.
Case Study 2: Graviton Migration
- Scenario: E-commerce API running on m5.large (Intel).
- Action: Switched to m6g.large (AWS Graviton2).
- Outcome: 20% lower instance cost and 15% better throughput.
12. Optimization Checklist
Related Skills
42-cost-engineering/infra-sizing
42-cost-engineering/budget-guardrails
42-cost-engineering/cost-observability
1---2name: cloud-cost-models3description: Comprehensive guide to cloud pricing models, cost structures, and optimization strategies across major providers.4---5
6# Cloud Cost Models and Pricing
7
8## Overview
9
10Cloud cost management (FinOps) is the practice of bringing financial accountability to the variable spend model of cloud computing. Understanding the underlying cost models of major providers is the foundation of building cost-efficient, scalable systems.
11
12**Core Principle**: "Optimize for value, not just cost. Move from 'how much did we spend' to 'how much value did we get for our spend'."
13
14---
15
16## 1. Cloud Pricing Fundamentals
17
18Cloud providers typically use a consumption-based model with three primary levers:
19
201. **Compute**: Charged by time (seconds/hours) and capacity (CPU/RAM).
212. **Storage**: Charged by volume (GB/month), redundancy level, and performance (IOPS).
223. **Data Transfer**: Usually free for "Inbound", charged for "Outbound" (Egress) and sometimes between internal zones/regions.
23
24### The Compute Continuum
25
26| Model | Pricing Metric | Best For | Typical Provider Product |
27| :--- | :--- | :--- | :--- |
28| **Virtual Machines** | Unit/Hour or Unit/Second | Consistent, legacy, or long-running apps | EC2, GCE, Azure VM |
29| **Containers** | Resource Requests (CPU/RAM) | Microservices, dynamic scaling | Fargate, Cloud Run, ACI |
30| **Serverless** | Requests + Execution Duration | Event-driven, intermittent traffic | Lambda, Cloud Functions |
31
32---
33
34## 2. AWS Pricing Model
35
36AWS uses a complex but granular pricing structure.
37
38### EC2 (Elastic Compute Cloud)
39* **On-Demand**: Lowest commitment, highest cost. Pay by the second.
40* **Reserved Instances (RI)**: Up to 72% discount for 1-3 year commitment. Best for steady-state workloads.
41* **Savings Plans**: Flexible 1-3 year commitment ($/hour) across EC2, Fargate, and Lambda.
42* **Spot Instances**: Up to 90% discount. AWS can reclaim with 2-minute notice. Best for stateless, fault-tolerant apps (CI/CD, batch processing).
43
44### S3 (Simple Storage Service)
45* **S3 Standard**: Active data ($0.023/GB).
46* **S3 Intelligent-Tiering**: Auto-moves data based on access patterns ($0.023/GB + monitoring fee).
47* **S3 Standard-IA**: Infrequent access, fast retrieval ($0.0125/GB).
48* **S3 Glacier Instant Retrieval**: Archival data, millisecond retrieval ($0.004/GB).
49* **S3 Glacier Deep Archive**: Long-term storage (7-10 years), 12-hour retrieval ($0.00099/GB).
50
51### Lambda
52* **Requests**: $0.20 per 1M requests.
53* **Duration**: Calculated in GB-seconds (Memory allocated × Duration).
54* **Provisioned Concurrency**: Extra fee to keep functions "warm" to avoid cold starts.
55
56### RDS (Relational Database Service)
57* **Instance**: Based on type (db.m5.large, etc.).
58* **Storage**: Multi-AZ doubles instance and storage costs.
59* **I/O**: Charged per million I/O requests for some engine types.
60
61### Data Transfer Costs
62* **Ingress (Internet to AWS)**: Free.
63* **Egress (AWS to Internet)**: ~$0.09/GB (first 10TB).
64* **Inter-AZ**: $0.01/GB (both directions).
65* **Inter-Region**: $0.02/GB.
66
67---
68
69## 3. GCP Pricing Model
70
71GCP emphasizes simplicity and "Sustained Use Discounts".
72
73### Compute Engine
74* **Standard**: Pay-as-you-go.
75* **Sustained Use Discounts (SUD)**: Automatic discounts (up to 30%) for running instances for a large portion of the month.
76* **Committed Use Discounts (CUD)**: 1 or 3-year commitment for specific vCPU/RAM amounts.
77* **Preemptible VMs**: Equivalent to AWS Spot, but fixed 24-hour max runtime and fixed ~80% discount.
78
79### Cloud Storage
80* **Standard**: Hot data.
81* **Nearline**: Data accessed < once/month.
82* **Coldline**: Data accessed < once/quarter.
83* **Archive**: Data accessed < once/year.
84
85### BigQuery
86* **Analysis (On-Demand)**: $5 per TB scanned.
87* **Analysis (Capacity/Flat-rate)**: Reserved slots (vCPUs) for predictable high-volume billing.
88* **Storage**: $0.02/GB (Active), $0.01/GB (Long-term > 90 days).
89
90---
91
92## 4. Azure Pricing Model
93
94### Virtual Machines
95* **Pay-as-you-go**: Standard rates.
96* **Reserved Virtual Machine Instances**: 1 or 3-year commitment (up to 72% savings).
97* **Azure Hybrid Benefit**: Use existing on-premises Windows Server/SQL Server licenses on Azure to save up to 40%.
98
99### Blob Storage
100* **Hot**: Frequently accessed.
101* **Cool**: Stored for 30+ days.
102* **Archive**: Stored for 180+ days.
103
104### Functions
105* **Consumption Plan**: Billed based on executions and execution time.
106* **Premium Plan**: Avoids cold starts, allows VNet integration, billed per vCPU and Memory.
107
108---
109
110## 5. Hidden Costs (The "Silent Killers")
111
112Many teams blow their budgets on items that aren't the primary compute instances:
113
1141. **Data Egress**: Moving data out of the cloud or between regions is expensive.
1152. **NAT Gateways**: AWS charges ~$0.045 per GB processed through a NAT Gateway *plus* the hourly fee for the gateway itself.
1163. **Load Balancers**: LCU (Load Balancer Capacity Units) can scale costs significantly with high connection counts or high throughput.
1174. **Logging & Monitoring**: Storing multi-terabyte internal logs in CloudWatch or Datadog can often exceed the cost of the application itself.
1185. **Unused Elastic IPs**: AWS charges for IPs that are allocated but *not* attached to a running instance.
1196. **Snapshots & Backups**: Retaining daily snapshots of 10TB volumes indefinitely.
120
121---
122
123## 6. Cost Optimization Strategies
124
125### The Optimization Pyramid
1261. **Right-Sizing**: Ensure instance sizes match actual utilization (CPU < 40% means you should downsize).
1272. **Modernization**: Move from VMs to Fargate/Lambda or Graviton (ARM) processors. Graviton typically offers 40% better price-performance.
1283. **Deletions**: Clean up "unattached" resources (EBS volumes, EIPs, Load Balancers).
1294. **Purchasing Options**: Apply RIs and Savings Plans *after* right-sizing.
130
131### Storage Lifecycle Policy Example (S3)
132```json
133{
134 "Rules": [
135 {
136 "ID": "MoveToIAAndGlacier",
137 "Prefix": "logs/",
138 "Status": "Enabled",
139 "Transitions": [
140 { "Days": 30, "StorageClass": "STANDARD_IA" },
141 { "Days": 90, "StorageClass": "GLACIER" }
142 ],
143 "Expiration": { "Days": 365 }
144 }
145 ]
146}
147```
148
149---
150
151## 7. Cost Allocation and Tagging
152
153If you can't measure it, you can't manage it.
154
155### Required Tags Hierarchy
156* **Project**: `Project: ProjectPhoenix`
157* **Environment**: `Env: Prod`, `Env: Dev`
158* **Owner**: `Owner: TeamAlpha`
159* **Cost Center**: `CostCenter: CC-9901`
160
161### enforcement with Terraform
162```hcl
163resource "aws_instance" "example" {
164 ami = "ami-12345678"
165 instance_type = "t3.medium"
166
167 tags = {
168 Name = "PhoenixAPI"
169 Environment = "Prod"
170 Owner = "TeamAlpha"
171 CostCenter = "12345"
172 }
173}
174```
175
176---
177
178## 8. FinOps Principles (Crawl, Walk, Run)
179
180The **FinOps Foundation** defines the lifecycle:
181
1821. **Inform**: Visibility into spend. Allocation, tagging, and reporting.
1832. **Optimize**: Real-time decision making. Right-sizing and identifying waste.
1843. **Operate**: Aligning teams to business goals. Budgets, unit economics, and governance.
185
186| Phase | Activities |
187| :--- | :--- |
188| **Crawl** | Spreadsheet reports, basic tags, monthly reviews. |
189| **Walk** | Multi-cloud dashboards, automated alerts, RI purchases. |
190| **Run** | Automated right-sizing, unit-cost tracking, AI-driven anomaly detection. |
191
192---
193
194## 9. Tools and Integration
195
196* **Native**: AWS Cost Explorer, GCP Billing, Azure Cost Management.
197* **Infrastructure as Code**: **Infracost** (shows cost changes in Pull Requests).
198* **Kubernetes**: **Kubecost** (allocates cluster costs to namespaces/pods).
199* **Anomaly detection**: AWS Cost Anomaly Detection (Machine Learning based).
200
201---
202
203## 10. TCO (Total Cost of Ownership) Calculation
204
205Avoid the "Sticker Price" trap. TCO includes:
206* **Direct Costs**: Server, Storage, Network.
207* **Indirect Costs**: Employee time for patching, DBA time for backups, security compliance.
208* **Risk Cost**: Cost of downtime if self-hosting vs. provider SLA.
209
210### TCO Calculation Table (Example: Self-Hosted vs. Managed DB)
211
212| Aspect | Self-Hosted (EC2) | Managed (RDS) |
213| :--- | :--- | :--- |
214| **Instance Cost** | $100/mo | $140/mo |
215| **Storage/Backup**| $20/mo | $30/mo |
216| **Engineer Hours**| 10 hrs ($1000) | 1 hr ($100) |
217| **Total Cost** | **$1120/mo** | **$270/mo** |
218| **Winner** | | ✅ **RDS** |
219
220---
221
222## 11. Real Cost Optimization Case Studies
223
224### Case Study 1: The "Zombie" Resource Cleanup
225* **Scenario**: A company was spending $50k/month on AWS.
226* **Discovery**: $8k was spent on EBS volumes not attached to any VM.
227* **Action**: Ran a script to find and delete volumes unattached > 14 days.
228* **Outcome**: Immediate $8,000/month (16%) savings.
229
230### Case Study 2: Graviton Migration
231* **Scenario**: E-commerce API running on m5.large (Intel).
232* **Action**: Switched to m6g.large (AWS Graviton2).
233* **Outcome**: 20% lower instance cost and 15% better throughput.
234
235---
236
237## 12. Optimization Checklist
238
239* [ ] **Tagging**: Are 100% of resources tagged with `CostCenter`?
240* [ ] **Right-Sizing**: Do any instances have < 10% average CPU over 7 days?
241* [ ] **Orphans**: Are there unattached EBS volumes or ELBs?
242* [ ] **Storage**: Are S3 lifecycle policies active for `logs/` buckets?
243* [ ] **Compute**: Are we using Spot instances for CI/CD runners?
244* [ ] **Networking**: Are we transferring data across regions unnecessarily?
245* [ ] **Commitment**: Do we have 1-year Savings Plans for our "baseline" load?
246
247## Related Skills
248* `42-cost-engineering/infra-sizing`
249* `42-cost-engineering/budget-guardrails`
250* `42-cost-engineering/cost-observability`