Outcomes
- Monthly GCP run rate: $28,000 to $14,000.
- Performance environment retired: about $540 a month.
The problem
After the move from AWS, which I led, the bill sat at $28,000 a month. Slow API routes kept extra Cloud Run instances busy, analytics queries scanned whole tables, pre-production ran all night, and a standing performance environment and leaked resources added cost every month.
What I built
- Made the API faster so it needs fewer instances: the API performance programme, concurrency and minimum-instance tuning, and Sidekiq workers resized per region.
- Repointed analytics datasets to pre-built BigQuery fact tables refreshed by scheduled queries, and made the largest dataset prune partitions.
- Shut down pre-production Cloud Run and Cloud SQL overnight and at weekends, across every pre-prod project.
- Retired the performance environment (three projects and their pipelines in six repos) in favour of an on-demand, scrubbed copy of production data.
- Right-sized Redis on evidence: pre-prod went from 3 GB to 1 GB after a 30-day peak under 17 MB.
Architecture and stack
- GCP: Cloud Run, Cloud SQL, Memorystore, BigQuery, Cloud Scheduler
- Terraform
- GitHub Actions
- Billing export in BigQuery