7ď¸âŁ Compute Services - Overview¶
Learn where to run your applications on Google Cloud Platform.
đ Table of Contents¶
- Introduction
- Compute Options Comparison
- Decision Tree
- Service Categories
- Architecture Patterns
- Cost Comparison
- Quick Reference
Introduction¶
GCP offers multiple compute options to run your applications, from traditional VMs to serverless containers. Choose based on your requirements for control, scalability, and management overhead.
Compute Spectrum¶
More Control Less Management
| |
v v
âââââââââââââââŹâââââââââââââââŹâââââââââââââââŹââââââââââââââŹâââââââââââââââ
â Compute â GKE â Cloud Run â App Engine â Cloud â
â Engine â (Kubernetes) â (Containers) â (PaaS) â Functions â
â (IaaS) â (CaaS) â â â (Serverless) â
âââââââââââââââ´âââââââââââââââ´âââââââââââââââ´ââââââââââââââ´âââââââââââââââ
Compute Options Comparison¶
Feature Matrix¶
| Feature | Compute Engine | GKE | Cloud Run | App Engine | Cloud Functions |
|---|---|---|---|---|---|
| Type | IaaS | CaaS | Serverless Containers | PaaS | FaaS |
| Control | Full | High | Medium | Low | Minimal |
| Scaling | Manual/Auto | Auto | Auto | Auto | Auto |
| Cold Start | None | None | ~1s | ~5s | ~1s |
| Min Instances | 1 | 1 | 0 | 1 | 0 |
| Max Instances | Unlimited | Unlimited | 1000 | Unlimited | 1000 |
| Pricing | Per second | Per second | Per 100ms | Per hour | Per 100ms |
| Free Tier | Yes | No | Yes | Yes | Yes |
| Custom Runtime | Yes | Yes | Yes | Limited | No |
| Stateful | Yes | Yes | Limited | Limited | No |
| GPU Support | Yes | Yes | No | No | No |
| SSH Access | Yes | Yes | No | No | No |
Decision Tree¶
Start: What do you need to run?
|
ââ> Need full OS control? ââ> Compute Engine
|
ââ> Running containers?
| ââ> Need orchestration? ââ> GKE
| ââ> Simple container? ââ> Cloud Run
|
ââ> Web application?
| ââ> Need custom runtime? ââ> Compute Engine / Cloud Run
| ââ> Standard runtime? ââ> App Engine
|
ââ> Event-driven function? ââ> Cloud Functions
Detailed Decision Criteria¶
Choose Compute Engine when: - Need full control over OS and infrastructure - Running legacy applications - Require specific hardware (GPUs, custom CPUs) - Need persistent local storage - Running Windows workloads
Choose GKE when: - Running microservices architecture - Need container orchestration - Multi-cloud portability required - Complex deployment patterns - Need service mesh (Istio)
Choose Cloud Run when: - Running stateless containers - Need automatic scaling to zero - Pay-per-use pricing preferred - Simple deployment required - HTTP-based workloads
Choose App Engine when: - Building web applications - Need managed platform - Standard runtimes sufficient - Integrated services needed - Quick deployment required
Choose Cloud Functions when: - Event-driven workloads - Lightweight processing - Serverless preferred - Short-lived executions - Simple single-purpose functions
Service Categories¶
1. Infrastructure as a Service (IaaS)¶
Compute Engine - Virtual machines in the cloud - Full control over OS and configuration - Persistent disks and local SSDs - Custom machine types - Preemptible and Spot VMs
âââââââââââââââââââââââââââââââââââââââ
â Compute Engine Instance â
âââââââââââââââââââââââââââââââââââââââ¤
â Your Application â
â Your Runtime â
â Your OS (Linux/Windows) â
âââââââââââââââââââââââââââââââââââââââ¤
â Google Manages: â
â - Physical hardware â
â - Network infrastructure â
â - Security patches (optional) â
âââââââââââââââââââââââââââââââââââââââ
2. Container as a Service (CaaS)¶
Google Kubernetes Engine (GKE) - Managed Kubernetes clusters - Container orchestration - Auto-scaling and auto-repair - Multi-zone and regional clusters - Workload identity and security
âââââââââââââââââââââââââââââââââââââââ
â GKE Cluster â
âââââââââââââââââââââââââââââââââââââââ¤
â Your Containers â
â Your Configuration â
âââââââââââââââââââââââââââââââââââââââ¤
â Google Manages: â
â - Kubernetes control plane â
â - Node pools â
â - Networking â
â - Upgrades â
âââââââââââââââââââââââââââââââââââââââ
3. Platform as a Service (PaaS)¶
App Engine - Fully managed application platform - Standard and Flexible environments - Built-in services (Memcache, Task Queue) - Traffic splitting and versioning - Automatic scaling
âââââââââââââââââââââââââââââââââââââââ
â App Engine â
âââââââââââââââââââââââââââââââââââââââ¤
â Your Application Code â
âââââââââââââââââââââââââââââââââââââââ¤
â Google Manages: â
â - Runtime environment â
â - Scaling â
â - Load balancing â
â - Monitoring â
â - Infrastructure â
âââââââââââââââââââââââââââââââââââââââ
4. Serverless Containers¶
Cloud Run - Fully managed serverless containers - Scale to zero - Pay per use - Any language, any library - Built on Knative
âââââââââââââââââââââââââââââââââââââââ
â Cloud Run â
âââââââââââââââââââââââââââââââââââââââ¤
â Your Container â
âââââââââââââââââââââââââââââââââââââââ¤
â Google Manages: â
â - Container runtime â
â - Auto-scaling (0-1000) â
â - Load balancing â
â - HTTPS endpoints â
â - Infrastructure â
âââââââââââââââââââââââââââââââââââââââ
5. Function as a Service (FaaS)¶
Cloud Functions - Event-driven serverless functions - Automatic scaling - Pay per invocation - Integrated with GCP services - 1st and 2nd gen runtimes
âââââââââââââââââââââââââââââââââââââââ
â Cloud Functions â
âââââââââââââââââââââââââââââââââââââââ¤
â Your Function Code â
âââââââââââââââââââââââââââââââââââââââ¤
â Google Manages: â
â - Runtime environment â
â - Scaling â
â - Event triggers â
â - Infrastructure â
â - Everything else â
âââââââââââââââââââââââââââââââââââââââ
Architecture Patterns¶
Pattern 1: Traditional Web Application¶
Internet
|
v
âââââââââââââââââââââââ
â Cloud Load â
â Balancer â
ââââââââââââŹâââââââââââ
|
ââââââââ´âââââââ
v v
ââââââââââ ââââââââââ
â VM 1 â â VM 2 â <-- Compute Engine
â Web â â Web â
â Server â â Server â
ââââââŹââââ âââââŹâââââ
| |
âââââââŹââââââ
v
ââââââââââââââââ
â Cloud SQL â
ââââââââââââââââ
Use Case: Traditional monolithic applications, legacy systems
Pattern 2: Microservices on Kubernetes¶
Internet
|
v
âââââââââââââââââââââââ
â Cloud Load â
â Balancer â
ââââââââââââŹâââââââââââ
|
ââââââââ´âââââââââââââââââââ
â GKE Cluster â
â ââââââââââââââââââââ â
â â Ingress â â
â ââââââââââŹââââââââââ â
â | â
â ââââââââââ´ââââââââââ â
â â Service Mesh â â
â â (Istio) â â
â ââââââââââŹââââââââââ â
â | â
â ââââââŹââââ´ââââŹâââââ â
â âSvc1â Svc2 âSvc3â â
â ââââââ´ââââââââ´âââââ â
âââââââââââââââââââââââââââ
Use Case: Microservices, complex applications, multi-team development
Pattern 3: Serverless Architecture¶
Internet
|
v
âââââââââââââââââââââââ
â Cloud Load â
â Balancer â
ââââââââââââŹâââââââââââ
|
ââââââââ´âââââââ
v v
ââââââââââââ ââââââââââââ
â Cloud â â Cloud â
â Run â â Run â
â Service1 â â Service2 â
ââââââŹââââââ âââââââŹâââââ
| |
ââââââââŹââââââââ
v
âââââââââââââââââ
â Firestore â
âââââââââââââââââ
Use Case: Modern applications, variable traffic, cost optimization
Pattern 4: Event-Driven Processing¶
ââââââââââââââââ
â Cloud â
â Storage â
ââââââââŹââââââââ
|
| (Event)
v
ââââââââââââââââ ââââââââââââââââ
â Cloud ââââââ>â Cloud â
â Functions â â Pub/Sub â
ââââââââââââââââ ââââââââŹââââââââ
|
v
ââââââââââââââââ
â BigQuery â
ââââââââââââââââ
Use Case: Data processing, ETL, event handling
Pattern 5: Hybrid Architecture¶
âââââââââââââââââââââââââââââââââââââââ
â Frontend (App Engine) â
ââââââââââââââââŹâââââââââââââââââââââââ
|
ââââââââââââ´âââââââââââ
v v
ââââââââââââ ââââââââââââââââ
â Cloud â â Compute â
â Run â â Engine â
â (API) â â (Legacy) â
ââââââŹââââââ ââââââââŹââââââââ
| |
âââââââââââŹââââââââââ
v
ââââââââââââââââ
â Cloud SQL â
ââââââââââââââââ
Use Case: Gradual migration, mixed workloads
Cost Comparison¶
Monthly Cost Example (us-central1)¶
Scenario: Web application with 2 vCPUs, 8GB RAM, running 24/7
| Service | Configuration | Monthly Cost | Notes |
|---|---|---|---|
| Compute Engine | n1-standard-2 | ~$49 | Sustained use discount |
| Compute Engine | e2-standard-2 | ~$33 | Cheaper machine type |
| Compute Engine | Spot VM | ~$10 | Can be preempted |
| GKE | 1 node (e2-standard-2) | ~$73 | Includes cluster fee |
| Cloud Run | 2 vCPU, 8GB, 1M requests | ~$50 | Pay per use |
| App Engine | F2 instance, 24/7 | ~$120 | Flexible environment |
| Cloud Functions | 1M invocations, 512MB | ~$5 | Event-driven only |
Cost Optimization Strategies¶
Compute Engine: - Use committed use discounts (up to 57% off) - Use sustained use discounts (automatic) - Use Spot VMs for fault-tolerant workloads (up to 91% off) - Right-size instances - Use preemptible VMs for batch processing
GKE: - Use Autopilot mode (pay only for pods) - Enable cluster autoscaling - Use Spot VMs for node pools - Right-size pod requests - Use node auto-provisioning
Cloud Run: - Set minimum instances to 0 - Optimize container startup time - Use concurrency settings - Set appropriate CPU allocation - Use request timeout limits
App Engine: - Use automatic scaling - Set max instances limit - Use Standard environment when possible - Optimize instance class - Use traffic splitting for gradual rollouts
Cloud Functions: - Optimize memory allocation - Reduce cold starts - Use appropriate timeout - Batch operations when possible - Use Pub/Sub for async processing
Quick Reference¶
Compute Engine¶
# Create VM instance
gcloud compute instances create my-vm \
--zone=us-central1-a \
--machine-type=e2-medium \
--image-family=debian-11 \
--image-project=debian-cloud
# SSH into instance
gcloud compute ssh my-vm --zone=us-central1-a
# Stop instance
gcloud compute instances stop my-vm --zone=us-central1-a
# Delete instance
gcloud compute instances delete my-vm --zone=us-central1-a
GKE¶
# Create cluster
gcloud container clusters create my-cluster \
--zone=us-central1-a \
--num-nodes=3
# Get credentials
gcloud container clusters get-credentials my-cluster \
--zone=us-central1-a
# Deploy application
kubectl apply -f deployment.yaml
# Delete cluster
gcloud container clusters delete my-cluster --zone=us-central1-a
Cloud Run¶
# Deploy container
gcloud run deploy my-service \
--image=gcr.io/my-project/my-image \
--platform=managed \
--region=us-central1 \
--allow-unauthenticated
# Update service
gcloud run services update my-service \
--region=us-central1 \
--memory=512Mi
# Delete service
gcloud run services delete my-service --region=us-central1
App Engine¶
# Deploy application
gcloud app deploy app.yaml
# View application
gcloud app browse
# View logs
gcloud app logs tail
# Set traffic split
gcloud app services set-traffic default \
--splits=v1=0.5,v2=0.5
Cloud Functions¶
# Deploy function
gcloud functions deploy my-function \
--runtime=python39 \
--trigger-http \
--allow-unauthenticated \
--entry-point=main
# Call function
gcloud functions call my-function
# View logs
gcloud functions logs read my-function
# Delete function
gcloud functions delete my-function
Service Limits¶
Compute Engine¶
| Resource | Default Limit | Notes |
|---|---|---|
| CPUs per region | 24 | Can request increase |
| Instances per region | 24 | Can request increase |
| Persistent disk size | 64 TB | Per disk |
| Local SSD | 9 TB | Per instance |
| Network egress | 7 Gbps | Per vCPU |
GKE¶
| Resource | Default Limit | Notes |
|---|---|---|
| Clusters per project | 50 | Soft limit |
| Nodes per cluster | 15,000 | Standard mode |
| Pods per node | 110 | Default |
| Services per cluster | 10,000 | Recommended |
| Namespaces per cluster | 10,000 | Recommended |
Cloud Run¶
| Resource | Default Limit | Notes |
|---|---|---|
| Services per region | 1,000 | Soft limit |
| Concurrent requests | 1,000 | Per container |
| Memory | 32 GB | Maximum |
| CPUs | 8 | Maximum |
| Request timeout | 60 minutes | Maximum |
App Engine¶
| Resource | Default Limit | Notes |
|---|---|---|
| Applications per project | 1 | Hard limit |
| Services per application | 105 | Soft limit |
| Versions per service | 210 | Soft limit |
| Instances per version | 200 | Automatic scaling |
| Request size | 32 MB | Maximum |
Cloud Functions¶
| Resource | Default Limit | Notes |
|---|---|---|
| Functions per project | 1,000 | Per region |
| Concurrent executions | 1,000 | Per function |
| Memory | 8 GB | Maximum |
| Timeout | 60 minutes | 2nd gen |
| Deployment size | 100 MB | Compressed |
Best Practices¶
General¶
â
Choose the right compute option for your workload
â
Use managed services when possible
â
Implement auto-scaling
â
Use health checks
â
Enable logging and monitoring
â
Implement proper security (IAM, VPC)
â
Use infrastructure as code (Terraform)
â
Tag resources for cost tracking
â
Implement disaster recovery
â
Regular security updates
Performance¶
â
Choose appropriate machine types
â
Use regional resources for HA
â
Implement caching strategies
â
Optimize container images
â
Use CDN for static content
â
Implement connection pooling
â
Monitor and optimize costs
â
Use appropriate storage types
â
Implement rate limiting
â
Load test before production
Security¶
â
Use service accounts with least privilege
â
Enable VPC Service Controls
â
Use private Google access
â
Implement network policies
â
Enable audit logging
â
Use Secret Manager for credentials
â
Implement DDoS protection
â
Regular security scanning
â
Use HTTPS/TLS everywhere
â
Implement authentication and authorization
Next Steps¶
- Compute Engine - Virtual machines and infrastructure
- Google Kubernetes Engine - Container orchestration
- Cloud Run - Serverless containers
- App Engine - Platform as a Service
- Cloud Functions - Serverless functions
- Compute Comparison - Detailed comparison
- Best Practices - Production guidelines
Additional Resources¶
- Compute Engine Documentation
- GKE Documentation
- Cloud Run Documentation
- App Engine Documentation
- Cloud Functions Documentation
- Pricing Calculator
- Architecture Center
Last Updated: March 2026
Status: â
Complete