GCP Pricing Guide: Understanding and Optimizing Costs
GCP pricing is uniquely structured — per-second billing, sustained-use discounts, and committed-use discounts make it different from AWS and Azure. Understanding this model is key to reducing your GCP bill without sacrificing performance.
What You’ll Learn
- Using the GCP Pricing Calculator for cost estimation
- Sustained-use discounts (automatic, no commitment)
- Committed-use discounts (1 or 3 year)
- Preemptible and Spot VMs for interruptible workloads
- Custom machine types for exact-fit sizing
- Network egress cost optimization
- Cloud Storage classes and object lifecycle
- BigQuery slot pricing and reservation models
- Budget alerts and cost anomaly detection
Why It Matters
GCP’s pricing model is the most flexible among the big three, but also the most nuanced. Teams that don’t understand sustained-use discounts, custom machine types, and preemptible VMs can overpay by 40-60%. DodaTech reduced GCP costs for its analytics pipeline by 55% using preemptible VMs and committed-use discounts for baseline compute.
flowchart LR
A[Pricing Calculator] --> B[Sustained-Use Discount]
A --> C[Committed-Use Discount]
A --> D[Preemptible VMs]
B --> E[Automatic 30%]
C --> F[Up to 70%]
D --> G[60-91% Off]
A --> H[Custom Machine Types]
A --> I[Storage Classes]
style D fill:#ea4335,color:#fff
1. GCP Pricing Calculator
Before provisioning, estimate costs with the GCP Pricing Calculator. It supports Compute Engine, Cloud Storage, BigQuery, Cloud Run, and 50+ other services.
# Use gcloud to estimate Compute Engine costs
gcloud compute instances create estimate-test \
--zone us-central1-a \
--machine-type e2-standard-4 \
--preemptible \
--dry-run
# Get pricing for a specific machine type
gcloud compute machine-types list \
--filter "name:e2-standard-4" \
--zones us-central1-aKey pricing factors:
- Region/zone (us-central1 is cheapest; asia-east1 is ~20% more)
- Machine type and custom vCPU/memory ratio
- Sustained-use discount (automatic after 25% of month)
- Commitment level (none / 1 year / 3 year)
- OS premium (Windows costs more than Linux)
2. Sustained-Use Discounts (SUDs)
GCP automatically applies sustained-use discounts for compute resources running more than 25% of a month. No commitment required.
Monthly usage → Discount
0-25% → 0%
25-50% → 10%
50-75% → 20%
75-100% → 30%# sustained_use_calculator.py
def sustained_use_cost(hourly_rate, hours_per_month):
discount_tiers = [
(0.25, 0.0),
(0.50, 0.10),
(0.75, 0.20),
(1.00, 0.30),
]
total = 0
remaining = hours_per_month
for tier_pct, discount in discount_tiers:
tier_hours = min(remaining, tier_pct * 730)
total += tier_hours * hourly_rate * (1 - discount)
remaining -= tier_hours
return total
cost = sustained_use_cost(0.05, 730)
on_demand = 730 * 0.05
print(f"On-demand: ${on_demand:.2f}")
print(f"With SUD: ${cost:.2f}")
print(f"Savings: {(1 - cost/on_demand)*100:.0f}%")Expected output:
On-demand: $36.50
With SUD: $28.47
Savings: 22%3. Committed-Use Discounts (CUDs)
For predictable workloads, commit to 1 or 3 years for up to 70% discount. CUDs apply to vCPU, memory, GPU, and even BigQuery slots.
# Purchase a committed-use discount for Compute Engine
gcloud compute commitments create prod-commitment \
--region us-central1 \
--plan 36-month \
--type vcpu-memory \
--resources vcpu=32,memory=128GB
# List existing commitments
gcloud compute commitments list \
--region us-central1CUD pricing example (n2-standard-8 in us-central1):
| Commitment | Discount | Monthly Cost |
|---|---|---|
| On-demand | 0% | $243.54 |
| 1-year | 24% | $185.09 |
| 3-year | 57% | $104.72 |
4. Preemptible and Spot VMs
Preemptible VMs run for up to 24 hours and can be terminated at any time. GCP Spot VMs (recommended) have no maximum runtime but still can be reclaimed.
# Create a preemptible VM
gcloud compute instances create batch-worker \
--zone us-central1-a \
--machine-type e2-standard-4 \
--preemptible
# Create a Spot VM (recommended over preemptible)
gcloud compute instances create spot-worker \
--zone us-central1-a \
--machine-type e2-standard-4 \
--provisioning-model=SPOT
# Use Node.js to handle preemption
# # prevent-gc.sh
# gcloud compute instances add-metadata spot-worker \
# --metadata=startup-script='echo "Handling preemption..."'5. Custom Machine Types
GCP lets you choose exact vCPU and memory ratios — you’re not locked into predefined types.
# Create a custom machine type: 6 vCPU, 20 GB RAM
gcloud compute instances create custom-worker \
--zone us-central1-a \
--custom-cpu 6 \
--custom-memory 20GB
# This is cheaper than n1-standard-8 (8 vCPU, 30GB RAM)
# if your workload only needs 6 vCPU and 20GBCustom type pricing: Pay only for what you need. A 6 vCPU / 20 GB custom VM costs ~20% less than bumping up to the next predefined tier.
6. Network Egress Costs
GCP egress pricing is complex: $0.12/GB to internet, $0.08/GB to other GCP regions, and free for egress within the same region.
# Monitor egress traffic
gcloud compute instances get-serial-port-output instance-1 \
--zone us-central1-a
# Use VPC Flow Logs to analyze traffic patterns
gcloud compute networks subnets update default \
--region us-central1 \
--enable-flow-logsOptimization strategies:
- Keep services in the same region to avoid cross-region egress
- Use Google’s premium tier for low-latency global routing (cheaper egress)
- Use Cloud CDN to serve content from edge locations, reducing origin egress costs
7. Cloud Storage Classes
| Class | Price/GB/Month | Retrieval | Best For |
|---|---|---|---|
| Standard | $0.020 | Instant | Active data |
| Nearline | $0.010 | 1 second | 30+ day data |
| Coldline | $0.004 | 1 second | 90+ day data |
| Archive | $0.0012 | Minutes+ hours | 365+ day data |
# Set object lifecycle policy
gcloud storage buckets update gs://dodatech-data \
--lifecycle-file=lifecycle.json
# lifecycle.json
# {
# "lifecycle": {
# "rule": [{
# "action": {"type": "SetStorageClass", "storageClass": "NEARLINE"},
# "condition": {"age": 30}
# }, {
# "action": {"type": "SetStorageClass", "storageClass": "COLDLINE"},
# "condition": {"age": 90}
# }, {
# "action": {"type": "Delete"},
# "condition": {"age": 365}
# }]
# }
# }8. BigQuery Slot Pricing
BigQuery charges either by on-demand ($5 per TB processed) or slots (dedicated capacity with flat rate).
# Check slot utilization
SELECT
project_id,
job_type,
SUM(total_slot_ms) / (1000 * 60 * 60) AS total_slot_hours
FROM `region-us.INFORMATION_SCHEMA.JOBS_BY_PROJECT`
WHERE DATE(creation_time) >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
GROUP BY project_id, job_type;Which to choose:
- On-demand: variable, low-volume, exploratory queries
- Flat-rate slots: predictable, high-volume production queries
Common Mistakes
Ignoring sustained-use discounts: SUDs are automatic, but if you shut down instances frequently, you lose the discount. Keep baseline instances running continuously.
Over-provisioning with predefined types: Using n1-standard-8 when a 6 vCPU / 20GB custom type would be cheaper and fit better.
No lifecycle policies on Cloud Storage: Data stays in Standard tier forever, paying 20x more than Archive for cold data.
Using on-demand for everything: Steady-state workloads without committed-use discounts overpay 50-70% compared to CUD pricing.
Cross-region data transfer: Each GB between regions costs $0.08-0.12. Design data pipelines to stay within one region.
Practice Questions
What is the difference between sustained-use and committed-use discounts? Answer: SUDs are automatic discounts for running VMs >25% of a month (up to 30%). CUDs require a 1- or 3-year commitment but offer up to 70% discount.
When should you use preemptible vs Spot VMs? Answer: Both offer similar discounts. Spot VMs have no maximum runtime (vs 24h for preemptible) and are preferred for most workloads.
How do custom machine types save money? Answer: They let you match vCPU and RAM exactly to your workload, avoiding paying for unused resources in predefined types.
What is the cheapest Cloud Storage class? Answer: Archive at $0.0012/GB/month, but with retrieval times of minutes to hours. Use it for compliance backups and long-term archives.
Challenge
Design a GCP cost-optimized architecture for a data analytics pipeline processing 5TB/day: use custom machine types for batch workers, preemptible VMs for parallel processing, committed-use discounts for the orchestrator services, Cloud Storage lifecycle for raw/intermediate/final data, BigQuery flat-rate slots for dashboard queries, and minimize network egress by colocating all services in us-central1.
FAQ
What’s Next
| Topic | Description |
|---|---|
| Deep dive into commitment-based discounts | |
| 80-90% discount on compute |
Related topics: Cloud Cost Optimization, Multi-Cloud, Cloud Computing
Built by the developers of Doda Browser, DodaZIP, and Durga Antivirus Pro.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro