Google Cloud Platform
Deploy and scale applications on Google Cloud - Cloud Run, Cloud Functions, BigQuery, GCS, Pub/Sub, and IAM with Terraform.
skill: Google Cloud Platform category: DevOps tags: [GCP, Google Cloud, Cloud Run, BigQuery, Cloud Functions] readingTime: 6
GCP's strengths are data analytics (BigQuery), machine learning (Vertex AI), and containerized workloads (Cloud Run). Cloud Run is the simplest way to run containers without managing infrastructure - it auto-scales to zero and charges only for request processing time.
Workflow
- Deploy containers with Cloud RunCloud Run runs any container, scales to zero, and charges per request - the simplest way to host APIs and web apps without server management.
- Query data with BigQueryBigQuery is a serverless, petabyte-scale analytical data warehouse - queries over billions of rows in seconds with no infrastructure management.
- Use Cloud Functions for event-driven tasksCloud Functions execute code in response to events (Pub/Sub messages, GCS uploads, HTTP requests) without managing servers.
- Configure IAM roles and service accountsLeast-privilege IAM prevents accidental or malicious access. Services should only have the permissions they need, nothing more.
- Stream events with Pub/SubPub/Sub decouples producers and consumers - services publish events without knowing who consumes them, enabling fan-out and retry.
Output Format
GCP setup: Cloud Run for containers, BigQuery for analytics, Cloud Functions for events, IAM service accounts, and Pub/Sub for messaging.
Cloud Run: gcloud run deploy + Terraform
BigQuery: client.query().to_dataframe()
Cloud Functions: @functions_framework.http
IAM: service account + minimal roles
Pub/Sub: publisher.publish() + subscriber.subscribe()Examples
Input
Output
Edge Cases & Gotchas
- Cloud Run cold starts - Cloud Run scales to zero by default - first request after idle period has cold start latency (1-3s). Set min-instances=1 for latency-sensitive services.
- BigQuery cost control - BigQuery charges by data scanned. Partition tables by date and cluster by frequently filtered columns to reduce bytes scanned per query.
- Pub/Sub at-least-once delivery - Pub/Sub guarantees at-least-once delivery - your handler must be idempotent. Use message deduplication IDs or check-then-process patterns.
- Quota limits - GCP has per-project and per-region quotas. Request quota increases early for BigQuery concurrent queries, Cloud Functions instances, and Cloud Run max instances.
When to Break These Rules
- Use AWS if your team has existing AWS expertise - migrating for GCP's sake is rarely worth the reskilling cost.
- Use Cloudflare Workers for edge computing at low latency - Cloud Run is regional, not edge.
Reference Files
https://cloud.google.com/docshttps://cloud.google.com/run/docs