Cost Optimization
CapEx vs. OpExβ
Cloud computing shifts infrastructure spend from CapEx (Capital Expenditure) to OpEx (Operating Expenditure):
| Model | Definition | Cloud equivalent |
|---|---|---|
| CapEx | Upfront investment in owned assets β servers, data centre hardware | On-premises infrastructure; reserved hardware purchases |
| OpEx | Ongoing operating costs β pay as you use | GCP 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 Type | How It Works | Applies To |
|---|---|---|
| Sustained Use Discounts (SUDs) | Automatic discount for VMs running >25% of the month β up to 30% off | GCE and Dataproc only; automatic, no action needed |
| Committed Use Discounts (CUDs) | Commit to a resource level for 1 or 3 years; up to 57% off | GCE, GKE, Cloud SQL, Cloud Run, AlloyDB |
| Spot VMs | Deeply discounted VMs (up to 91% off) that GCP may preempt with 30s notice | GCE, GKE node pools |
CUD Typesβ
| Type | What You Commit To | Flexibility |
|---|---|---|
| Resource-based CUD | Specific machine type (vCPUs + memory) in a region | Low β tied to machine type |
| Spend-based CUD | Dollar amount of hourly spend | High β 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.
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?
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.
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