GCP for DevOps — Discounts & Pricing

4 minute read

Discounts & Pricing

GCP offers several discount mechanisms to reduce costs for predictable workloads. Understanding committed use discounts (CUDs), sustained use discounts (SUDs), Spot VMs, and custom machine types helps DevOps teams optimize infrastructure spend significantly.

GCP Discount Types Overview

GCP Discount Landscape:
┌──────────────────────────────────────────────────────────┐
│                                                           │
│  Automatic Discounts          Commitment Discounts        │
│  ┌─────────────────────┐     ┌────────────────────────┐  │
│  │  Sustained Use       │     │  Committed Use (CUD)   │  │
│  │  • Auto-applied      │     │  • 1-year: ~37% off    │  │
│  │  • Up to 30% off     │     │  • 3-year: ~55% off    │  │
│  │  • Compute Engine    │     │  • Spend or resource    │  │
│  │  • After 25% month   │     │  • Non-cancellable     │  │
│  └─────────────────────┘     └────────────────────────┘  │
│                                                           │
│  Spot/Preemptible VMs         Free Tier / Always Free     │
│  ┌─────────────────────┐     ┌────────────────────────┐  │
│  │  Spot VMs            │     │  Free Tier              │  │
│  │  • Up to 91% off     │     │  • e2-micro (1/month)  │  │
│  │  • Can be preempted  │     │  • 5 GB Cloud Storage  │  │
│  │  • Batch, CI/CD      │     │  • 1 GB App Engine     │  │
│  │  • Max 24h runtime   │     │  • Many services       │  │
│  └─────────────────────┘     └────────────────────────┘  │
└──────────────────────────────────────────────────────────┘

Sustained Use Discounts (SUDs)

SUDs are automatic discounts applied when you run Compute Engine resources for a significant portion of the month. No commitment required.

Sustained Use Discount Tiers:
┌────────────────────────────────────────────────┐
│  Monthly Usage    │  Effective Discount         │
├────────────────────────────────────────────────┤
│  0% - 25%        │  Full price                 │
│  25% - 50%       │  20% discount on this tier  │
│  50% - 75%       │  40% discount on this tier  │
│  75% - 100%      │  60% discount on this tier  │
├────────────────────────────────────────────────┤
│  Full month       │  ~30% net discount          │
└────────────────────────────────────────────────┘

Note: SUDs apply to N1 and N2 machine types.
E2 and Tau machines do NOT get SUDs.

Committed Use Discounts (CUDs)

CUDs provide deeper discounts in exchange for 1-year or 3-year commitments.

Resource-based CUDs — Commit to specific vCPU and memory amounts:

# Create a 1-year resource-based CUD
$ gcloud compute commitments create my-cud-1year \
    --region=us-central1 \
    --resources=vcpu=16,memory=64GB \
    --plan=12-month \
    --type=COMPUTE_OPTIMIZED
Created [my-cud-1year].

# List existing commitments
$ gcloud compute commitments list --region=us-central1
NAME            REGION         STATUS   START_TIME            END_TIME              PLAN
my-cud-1year    us-central1    ACTIVE   2026-03-30T00:00:00   2027-03-30T00:00:00   12-month

Spend-based CUDs — Commit to a minimum spend per hour on specific services:

CUD Type 1-Year Discount 3-Year Discount Applicable To
Resource-based ~37% ~55% Compute Engine (vCPU, memory)
Spend-based ~25% ~52% Cloud SQL, Cloud Run, GKE

CUD vs SUD Comparison

Feature SUD CUD (Resource) CUD (Spend)
Commitment None 1 or 3 years 1 or 3 years
Max discount ~30% ~55% ~52%
Auto-applied Yes Yes (after purchase) Yes (after purchase)
Cancellable N/A No No
Flexibility Any VM Same region/type Same service
Scope Per project Per region Per region

Spot VMs (Preemptible)

Spot VMs are up to 60-91% cheaper but can be reclaimed by GCP with 30 seconds notice. Ideal for fault-tolerant, batch, and CI/CD workloads.

# Create a Spot VM
$ gcloud compute instances create batch-worker-1 \
    --zone=us-central1-a \
    --machine-type=e2-standard-4 \
    --provisioning-model=SPOT \
    --instance-termination-action=STOP \
    --image-family=debian-12 \
    --image-project=debian-cloud
Created [batch-worker-1].

# Create a Spot VM MIG for batch processing
$ gcloud compute instance-templates create spot-template \
    --machine-type=e2-standard-4 \
    --provisioning-model=SPOT \
    --instance-termination-action=DELETE \
    --image-family=debian-12 \
    --image-project=debian-cloud
Created [spot-template].

$ gcloud compute instance-groups managed create batch-pool \
    --zone=us-central1-a \
    --template=spot-template \
    --size=5
Created [batch-pool].

Spot VM Use Cases

Use Case Why Spot Works Savings
CI/CD build agents Short-lived, restartable 60-80%
Batch data processing Fault-tolerant, checkpointable 70-91%
Dev/test environments Non-critical, can restart 60-80%
Machine learning training Checkpoint + resume 60-91%
Rendering / transcoding Parallelizable, restartable 70-91%

Custom Machine Types

Instead of over-provisioning with predefined sizes, create VMs with exactly the CPU and memory you need:

# Create a custom machine type (4 vCPUs, 10 GB RAM)
$ gcloud compute instances create custom-vm \
    --zone=us-central1-a \
    --custom-cpu=4 \
    --custom-memory=10GB \
    --image-family=debian-12 \
    --image-project=debian-cloud
Created [custom-vm].

# Extended memory (more than 6.5 GB per vCPU)
$ gcloud compute instances create high-mem-vm \
    --zone=us-central1-a \
    --custom-cpu=2 \
    --custom-memory=24GB \
    --custom-extensions \
    --image-family=debian-12 \
    --image-project=debian-cloud
Created [high-mem-vm].

Cost Comparison: Standard vs Custom vs Spot

Configuration Monthly Cost Savings
e2-standard-4 (4 vCPU, 16 GB) ~$97/month Baseline
Custom (4 vCPU, 10 GB) ~$78/month ~20%
e2-standard-4 + CUD 1yr ~$61/month ~37%
e2-standard-4 + CUD 3yr ~$44/month ~55%
Spot e2-standard-4 ~$29/month ~70%

BigQuery Pricing Optimization

# Switch from on-demand to flat-rate for predictable BQ workloads
# On-demand: $6.25/TB scanned
# Flat-rate editions: Predictable monthly cost

# Check query costs before running
$ bq query --dry_run \
    'SELECT * FROM my_dataset.large_table WHERE date > "2026-01-01"'
Query successfully validated. Estimated bytes processed: 5368709120

# That's ~5 GB = ~$0.03 on-demand
# For heavy BQ usage, consider BigQuery editions

Cloud Storage Cost Optimization

Storage Class Use Case Monthly Cost/GB Retrieval Cost
Standard Frequent access $0.020 Free
Nearline Monthly access $0.010 $0.01/GB
Coldline Quarterly access $0.004 $0.02/GB
Archive Yearly access $0.0012 $0.05/GB
# Set lifecycle rules to move old data to cheaper classes
$ cat 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}
      }
    ]
  }
}

$ gcloud storage buckets update gs://my-data-bucket \
    --lifecycle-file=lifecycle.json
Updating gs://my-data-bucket/...

Common Mistakes

Mistake Impact Fix
Over-committing with CUDs Paying for unused capacity Start small, expand based on usage
Using Spot for stateful workloads Data loss on preemption Use Spot only for stateless/batch
Ignoring sustained use discounts Missing automatic savings Consolidate usage on eligible types
Standard storage for cold data 16x cost vs Archive class Apply lifecycle policies

Quick Reference

Task Command
Create CUD gcloud compute commitments create NAME --resources=vcpu=N,memory=MGB --plan=12-month
Create Spot VM gcloud compute instances create NAME --provisioning-model=SPOT
Custom machine type gcloud compute instances create NAME --custom-cpu=N --custom-memory=MGB
List commitments gcloud compute commitments list --region=REGION
Set storage lifecycle gcloud storage buckets update gs://BUCKET --lifecycle-file=FILE

Next → Cost Analysis & Automation

Updated: