Skip to content
gcp-resource-optimizer logo

GCP Resource Optimizer

gcp-resource-optimizer

Optimize Google Cloud Platform resource allocation and manage cloud credits efficiently. Use when planning GCP deployments, analyzing cloud spend, maximizing value from expiring credits, right-sizing instances, or designing cost-effective architectures. Triggers on GCP cost optimization, credit m...

SKILL.md

Full skill instructions

GCP Resource Optimizer

Maximize value from GCP resources and credits through strategic allocation.

Credit Burn Strategy

Credit Expiration Planning

When managing expiring credits:

  1. Audit current usage: gcloud billing accounts describe ACCOUNT_ID
  2. Calculate burn rate: Total credits ÷ Days remaining = Required daily spend
  3. Identify high-value uses: What creates lasting value vs. ephemeral compute?

High-Value Credit Uses

Lasting value (prioritize):

  • Training ML models (artifacts persist)
  • Building container images
  • Generating datasets
  • Running batch processing on accumulated work

Ephemeral (use strategically):

  • Compute instances (gone when shut down)
  • Development environments
  • Testing infrastructure

Cost Optimization Patterns

Compute Engine

Right-sizing instances:

# Check recommendations
gcloud recommender recommendations list \
  --project=PROJECT_ID \
  --location=ZONE \
  --recommender=google.compute.instance.MachineTypeRecommender

Cost-effective machine types:

NeedRecommendedWhy
General workloade2-mediumBest price/​performance
Memory-intensiven2-highmemBetter RAM ratio
CPU burste2-micro/​smallBurstable, cheap
ML trainingn1 + GPURequired for accelerators
Spot-tolerantSpot VMs60-91% discount

Preemptible/​Spot VMs:

  • 60-91% cheaper than standard
  • Can be terminated with 30s notice
  • Good for: batch jobs, fault-tolerant workloads, development
  • Bad for: production, stateful services

Cloud Run

Optimizing Cloud Run:

# Minimize cold starts and costs
spec:
  template:
    spec:
      containerConcurrency: 80  # Maximize requests per instance
      timeoutSeconds: 300
    metadata:
      annotations:
        autoscaling.knative.dev/​minScale: '0'  # Scale to zero
        autoscaling.knative.dev/​maxScale: '10'  # Cap costs
        run.googleapis.com/​cpu-throttling: 'true'  # CPU only when processing

Cloud Storage

Storage class optimization:

ClassUse CaseCost/​GB/​mo
StandardFrequent access~$0.020
NearlineMonthly access~$0.010
ColdlineQuarterly access~$0.004
ArchiveYearly access~$0.0012

Lifecycle rules:

{
  "lifecycle": {
    "rule": [
      {
        "action": {"type": "SetStorageClass", "storageClass": "NEARLINE"},
        "condition": {"age": 30}
      },
      {
        "action": {"type": "SetStorageClass", "storageClass": "COLDLINE"},
        "condition": {"age": 90}
      },
      {
        "action": {"type": "Delete"},
        "condition": {"age": 365}
      }
    ]
  }
}

BigQuery

Cost control:

-- Set maximum bytes billed
#standardSQL
-- @maximumBytesBilled 10000000000
SELECT * FROM dataset.table

Partitioning for cost reduction:

CREATE TABLE dataset.table
PARTITION BY DATE(timestamp_column)
CLUSTER BY user_id
AS SELECT * FROM source_table

Budget Alerts

Set up budget alerts:

gcloud billing budgets create \
  --billing-account=BILLING_ACCOUNT_ID \
  --display-name="Monthly Budget" \
  --budget-amount=100USD \
  --threshold-rule=percent=50 \
  --threshold-rule=percent=90 \
  --threshold-rule=percent=100

Resource Cleanup

Find Unused Resources

# Unused disks
gcloud compute disks list --filter="NOT users:*"

# Unused IPs
gcloud compute addresses list --filter="status=RESERVED"

# Idle VMs (by CPU)
gcloud monitoring time-series list \
  --filter='metric.type="compute.googleapis.com/​instance/​cpu/​utilization"' \
  --interval="start=2024-01-01T00:00:00Z"

Cleanup Script

#!/​bin/​bash
# cleanup_unused.sh - Review before running!

# List (don't delete) unused resources
echo "=== Unused Disks ==="
gcloud compute disks list --filter="NOT users:*" --format="table(name,zone,sizeGb)"

echo "=== Reserved IPs ==="
gcloud compute addresses list --filter="status=RESERVED" --format="table(name,region,address)"

echo "=== Snapshots older than 30 days ==="
gcloud compute snapshots list --filter="creationTimestamp<$(date -d '30 days ago' -Iseconds)" --format="table(name,diskSizeGb,creationTimestamp)"

Architecture Patterns for Cost

Serverless-First

Request → Cloud Run → Firestore → Done
         (scales to zero)  (pay per op)

vs.

Request → GKE → Cloud SQL → Done
         (always running)  (always running)

Batch Processing

Pub/​Sub → Cloud Functions → BigQuery (batch load)
                           (cheaper than streaming)

Development vs Production

Dev environment:

  • Spot/​preemptible VMs
  • Smaller machine types
  • Scale-to-zero services
  • Shared resources

Prod environment:

  • Committed use discounts (1-3 year)
  • Right-sized dedicated instances
  • Redundancy only where needed

Monitoring Setup

# Enable billing export to BigQuery
gcloud beta billing accounts describe ACCOUNT_ID

# Query costs
#standardSQL
SELECT
  service.description,
  SUM(cost) as total_cost
FROM `project.dataset.gcp_billing_export_v1_*`
WHERE _PARTITIONTIME >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
GROUP BY 1
ORDER BY 2 DESC

References

  • references/​pricing-cheatsheet.md - Quick pricing reference
  • references/​cost-queries.md - BigQuery cost analysis queries

More DevOps & CI/CD skills

Project scaffolding, deployment configuration, and CI/CD setup for Google ADK agents.

6K 472.6K
View

Set up tracing, logging, and monitoring for deployed ADK agents across Cloud Trace, BigQuery, and third-party platforms.

6K 472.6K
View

Enterprise Azure infrastructure architect generating Bicep or Terraform from workload descriptions.

1.5K 454.3K
View
azure-kubernetes logo
DevOps & CI/CD

azure-kubernetes

Plan and configure production-ready Azure Kubernetes Service clusters with Day-0 and Day-1 best practices.

1.5K 447.1K
View

Raw mechanical interfaces fusing Swiss typographic print with military terminal aesthetics. Rigid grids, extreme type scale contrast, utilitarian color, analog degradation effects. For data-heavy dashboards, portfolios, or editorial sites that need to feel like declassified blueprints.

92.7K 354.9K
View
just-scrape logo
DevOps & CI/CD

just-scrape

Web search, scraping, extraction, crawling, and monitoring via ScrapeGraph AI CLI.

69 245K
View

Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.

462 159.7K
View

Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.

462 159.1K
View
deploy-to-vercel logo
DevOps & CI/CD

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

31.9K 146.6K
View
programmatic-seo logo
DevOps & CI/CD

programmatic-seo

Build SEO-optimized pages at scale using templates, data, and proven playbook patterns.

53.3K 140.1K
View

Design and build isolated, reusable Convex backend components with clear boundaries and app-facing wrappers.

63 123.5K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View

Coding & apps AI tools

Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View
Imagica logo
Coding & apps

Imagica

Build a no-code AI app in minutes.

Freemium
View
E
Coding & apps

Emergent.sh

An IDE for code migration from legacy to modern frameworks through coding agents.

Freemium
View
Wonder Dynamics logo
Coding & apps

Wonder Dynamics

Automate CGI animation in live-action scenes

Paid
View
M
Coding & apps

Mixo

Launch a website in seconds with AI.

Paid
View
AI Code Convert logo
Coding & apps

AI Code Convert

Streamline Your Coding Experience with AI Code Helper

Free
View