Skip to main content

Cost Optimization

Docs: Cost optimisation on Google Cloud

CapEx vs. OpEx​

Cloud computing shifts infrastructure spend from CapEx (Capital Expenditure) to OpEx (Operating Expenditure):

ModelDefinitionCloud equivalent
CapExUpfront investment in owned assets β€” servers, data centre hardwareOn-premises infrastructure; reserved hardware purchases
OpExOngoing operating costs β€” pay as you useGCP on-demand pricing; billed monthly

Why this matters for the exam:

  • "Reduce upfront capital costs" β†’ migrate to GCP (CapEx β†’ OpEx shift)
  • "Predictable monthly spend" β†’ Committed Use Discounts (CUDs) β€” you keep OpEx but get a discount for a usage commitment
  • "Eliminate data centre refresh cycles" β†’ cloud removes hardware CapEx entirely

The exam often uses the CapEx/OpEx framing as justification for a cloud migration decision β€” recognise it as the financial rationale, not a technical constraint.

Docs: Total cost of ownership

Pricing Model Basics​

GCP uses on-demand pricing by default β€” pay per second with no upfront commitment. Discounts stack on top of on-demand rates.

Discount TypeHow It WorksApplies To
Sustained Use Discounts (SUDs)Automatic discount for VMs running >25% of the month β€” up to 30% offGCE and Dataproc only; automatic, no action needed
Committed Use Discounts (CUDs)Commit to a resource level for 1 or 3 years; up to 57% offGCE, GKE, Cloud SQL, Cloud Run, AlloyDB
Spot VMsDeeply discounted VMs (up to 91% off) that GCP may preempt with 30s noticeGCE, GKE node pools

CUD Types​

TypeWhat You Commit ToFlexibility
Resource-based CUDSpecific machine type (vCPUs + memory) in a regionLow β€” tied to machine type
Spend-based CUDDollar amount of hourly spendHigh β€” applies to any machine type in the family

Spend-based CUDs are more flexible but give a smaller discount. Use resource-based when you know exactly which machine types you'll run.

Rightsizing​

Cloud Recommender analyses VM CPU/memory utilisation and recommends:

  • Downsize β€” if average CPU is consistently below 50%, recommend a smaller machine type
  • Idle VM β€” if CPU is near 0%, recommend stopping or deleting

Apply recommendations from the Recommender API or directly in the Cloud Console under Active Assist.

Docs: VM rightsizing recommendations

Billing and Cost Visibility​

Billing Exports to BigQuery​

Export detailed billing data (line-item charges, labels, SKUs) to BigQuery for analysis.

  • Standard export β€” daily export of charges
  • Detailed export β€” includes resource-level cost breakdown; needed for showback/chargeback

Build dashboards in Looker Studio or run SQL queries to answer: Which team/project is spending the most? Which SKU drove this month's spike?

Docs: Cloud Billing data to BigQuery

Budgets and Alerts​

Set a billing budget on a billing account, project, or folder with alert thresholds (e.g. alert at 50%, 90%, 100% of budget). Alerts are sent via email or Pub/Sub.

Budgets do not stop spending β€” they only alert. To enforce a hard cap, configure a Pub/Sub alert that triggers a Cloud Function to disable billing on the project.

Docs: Set budgets and budget alerts

Cost Allocation​

Use labels on GCP resources (VMs, GCS buckets, BigQuery datasets) to tag them by team, environment, or cost centre. Labels flow through to billing exports, enabling per-team showback.

Best practice:

  • Define a labelling taxonomy at the organisation level (e.g. env: prod/staging/dev, team: platform/data/frontend)
  • Enforce mandatory labels via Organisation Policy constraints

Storage Cost Optimisation​

  • Use Cloud Storage lifecycle policies to auto-transition objects to cheaper classes over time β†’ Cloud Storage reference
  • Use BigQuery partitioning to reduce query cost (only scan the partitions you need)
  • Enable BigQuery table expiry on temporary or staging datasets

Unattended Projects and Resources​

Unattended Project Recommender β€” identifies projects with no human activity for 30+ days. Review and delete to eliminate waste.

Idle resource recommenders β€” also flags:

  • Unattached persistent disks
  • Idle IP addresses
  • Idle load balancers

Exam Tips​

  • "Predictable, steady-state workload" β†’ CUD (1 or 3 year)
  • "Fault-tolerant batch / ML training" β†’ Spot VMs (up to 91% off, handle preemption)
  • "Allocate cloud costs to individual teams" β†’ Labels + billing export to BigQuery
  • "Alert team when spend exceeds budget" β†’ Billing budget with Pub/Sub notification
  • SUDs are automatic β€” never say a customer needs to "enable" them; they apply automatically to eligible VMs

Official Documentation​