GCP Architecture Reference
Comprehensive guide for Google Cloud Platform services, patterns, and architecture framework.
Google Cloud Architecture Framework
Five Pillars
Operational Excellence
- Infrastructure as Code (Deployment Manager, Terraform)
- CI/CD with Cloud Build
- Monitoring with Cloud Monitoring (Stackdriver)
- SRE principles and SLOs
- Incident management
Security, Privacy, and Compliance
- Identity and Access Management (Cloud IAM)
- VPC Service Controls for data perimeter
- Binary Authorization for containers
- Data encryption (default at rest and in transit)
- Security Command Center
Reliability
- Multi-zone and multi-region deployments
- Load balancing and autoscaling
- Disaster recovery planning
- Chaos engineering practices
- SLIs, SLOs, and error budgets
Cost Optimization
- Committed Use Discounts
- Sustained Use Discounts (automatic)
- Preemptible VMs and Spot VMs
- Recommender for right-sizing
- Active Assist for optimization
Performance Optimization
- Cloud CDN and Media CDN
- Caching strategies (Memorystore)
- Database performance tuning
- Network optimization (Premium vs Standard tier)
- Regional and zonal resource placement
Core Services Architecture
Compute
Compute Engine
- Machine types: E2 (cost-optimized), N2 (balanced), C2 (compute-optimized), M2 (memory-optimized)
- Custom machine types for specific needs
- Preemptible VMs (up to 80% discount, max 24 hours)
- Spot VMs (similar to preemptible, better availability)
- Instance groups: Managed (with autoscaling), unmanaged
- Best practices: Use latest generation, committed use discounts, Spot for batch jobs
Cloud Run
- Fully managed serverless container platform
- Auto-scaling to zero
- Pay per request
- CPU allocated only during request handling
- Best practices: Stateless containers, optimize cold starts, use Cloud Run jobs for batch
Cloud Functions
- Event-driven serverless functions
- 1st gen: HTTP and background functions
- 2nd gen: Built on Cloud Run, better performance
- Event sources: Pub/Sub, Cloud Storage, Firestore, HTTP
- Best practices: Use 2nd gen, minimize cold starts, implement retry logic
Google Kubernetes Engine (GKE)
- Managed Kubernetes with GCP integration
- Autopilot mode: Fully managed, per-pod pricing
- Standard mode: More control, node management
- Workload Identity for secure service access
- Binary Authorization for deployment policies
- Best practices: Use Autopilot for simplicity, enable Workload Identity, implement network policies
App Engine
- Fully managed platform (PaaS)
- Standard environment (sandboxed, auto-scaling)
- Flexible environment (Docker containers, custom runtimes)
- Traffic splitting for canary deployments
- Best practices: Use Standard for web apps, Flexible for custom dependencies
Storage
Cloud Storage
- Storage classes: Standard, Nearline (30-day), Coldline (90-day), Archive (365-day)
- Object lifecycle management
- Object versioning and retention policies
- Autoclass for automatic tier transitions
- Requester pays for data transfer
- Best practices: Use Autoclass, enable versioning, implement lifecycle policies
Persistent Disk
- Types: Standard (HDD), Balanced SSD, SSD, Extreme
- Zonal and regional persistent disks
- Snapshots for backup (incremental)
- Disk resize without downtime
- Best practices: Use Balanced SSD for most workloads, enable snapshots
Filestore
- Managed NFS file storage
- Tiers: Basic (1-63.9 TB), Enterprise (1-10 TB, better performance)
- Backup to Cloud Storage
- Best practices: Use Enterprise for production, implement backups
Cloud Storage for Firebase
- Object storage for mobile and web apps
- Client SDKs for direct upload/download
- Security rules for access control
Database
Cloud SQL
- Managed MySQL, PostgreSQL, SQL Server
- High availability configuration (regional)
- Read replicas for scaling
- Automated backups and point-in-time recovery
- Best practices: Enable HA, use read replicas, implement connection pooling with Cloud SQL Proxy
Cloud Spanner
- Globally distributed relational database
- Horizontal scalability with strong consistency
- Multi-region for 99.999% availability
- TrueTime for global consistency
- Best practices: Design proper schema splits, use commit timestamps, optimize hotspots
Firestore (Native mode)
- NoSQL document database
- Real-time synchronization
- Offline support for mobile
- ACID transactions
- Best practices: Design document structure carefully, use collection group queries wisely
Bigtable
- NoSQL wide-column database
- Petabyte-scale with single-digit millisecond latency
- HBase API compatible
- Linear scalability by adding nodes
- Best practices: Design row keys to avoid hotspots, use replication for HA
Memorystore
- Managed Redis and Memcached
- Standard tier (HA with replica) and Basic tier
- Best practices: Use Standard tier for production, implement connection pooling
BigQuery
- Serverless data warehouse
- SQL analytics on petabyte-scale data
- Column-oriented storage
- Automatic caching and optimization
- Best practices: Partition and cluster tables, use approximate functions, control costs with quotas
Networking
VPC (Virtual Private Cloud)
- Global resource (subnets are regional)
- Custom or auto mode networks
- Firewall rules (stateful)
- VPC peering and Shared VPC
- Private Google Access for GCP services
- Best practices: Use custom mode VPC, plan IP ranges, implement firewall rules
Cloud Load Balancing
- Global load balancing (HTTP(S), TCP/SSL Proxy, external TCP/UDP)
- Regional load balancing (internal HTTP(S), internal TCP/UDP)
- Anycast IP for global distribution
- Backend services with health checks
- Best practices: Use global for multi-region, enable CDN, configure health checks
Cloud CDN
- Global content delivery network
- Cache invalidation and signed URLs
- Integration with Cloud Storage and compute
- Best practices: Enable compression, use cache-control headers
Cloud Interconnect and VPN
- Dedicated Interconnect (10 Gbps or 100 Gbps)
- Partner Interconnect (50 Mbps to 50 Gbps)
- Cloud VPN (HA VPN for 99.99% SLA)
- Best practices: Use HA VPN for redundancy, Dedicated Interconnect for high bandwidth
Cloud Armor
- DDoS protection and WAF
- Preconfigured and custom rules
- Adaptive protection (ML-based)
- Best practices: Enable for internet-facing services, use preconfigured rules
Private Service Connect
- Private connectivity to Google APIs and services
- Service Directory for service discovery
- Best practices: Use for all managed services in production
Serverless and Event-Driven
Pub/Sub
- Global message queue
- At-least-once delivery
- Push and pull subscriptions
- Message ordering and filtering
- Dead-letter topics
- Best practices: Use message attributes for filtering, implement idempotent processing
Eventarc
- Event-driven architecture
- Triggers for Cloud Run, Workflows, GKE
- Sources: Audit Logs, Pub/Sub, custom events
- Best practices: Use for decoupled architectures, implement event filtering
Cloud Scheduler
- Fully managed cron service
- HTTP, Pub/Sub, and App Engine targets
- Best practices: Use for periodic tasks, implement retry logic
Workflows
- Orchestrate and automate GCP and HTTP services
- YAML-based workflow definition
- Built-in error handling and retry
- Best practices: Use for complex multi-step processes, implement compensating transactions
Security and Identity
Cloud IAM
- Resource hierarchy: Organization -> Folders -> Projects -> Resources
- Roles: Primitive (Owner, Editor, Viewer), Predefined, Custom
- Service accounts for applications
- Workload Identity for GKE
- Best practices: Use predefined roles, least privilege, service accounts for apps
Cloud Key Management (KMS)
- Encryption key management
- Customer-managed encryption keys (CMEK)
- Hardware Security Module (HSM) backed
- Automatic key rotation
- Best practices: Enable automatic rotation, use separate keys per environment
Secret Manager
- Store API keys, passwords, certificates
- Versioning and access control
- Automatic rotation integration
- Best practices: Rotate secrets regularly, use IAM for access control
Security Command Center
- Centralized security and risk management
- Asset discovery and vulnerability scanning
- Threat detection and compliance monitoring
- Best practices: Enable all detectors, review findings regularly
VPC Service Controls
- Create security perimeters around GCP resources
- Prevent data exfiltration
- Best practices: Use for sensitive data, implement access levels
AI and Machine Learning
Vertex AI
- Unified ML platform
- AutoML for custom models
- Pre-trained models (Vision, Natural Language, etc.)
- MLOps with pipelines
- Best practices: Use AutoML for quick start, implement feature store
BigQuery ML
- Create and execute ML models using SQL
- Model types: Linear regression, logistic regression, clustering, etc.
- Integration with Vertex AI
- Best practices: Use for simple models, leverage BigQuery's scale
Architecture Patterns
High Availability
Multi-Zone Pattern
Global HTTP(S) Load Balancer
|
v
Managed Instance Group (multi-zone)
|
v
Cloud SQL (regional, HA configuration)
|
v
Cloud Storage (multi-region)
Multi-Region Pattern
Global HTTP(S) Load Balancer
|
├── Backend Service Region 1 (Cloud Run)
└── Backend Service Region 2 (Cloud Run)
|
v
Cloud Spanner (multi-region)
Serverless Architecture
Event-Driven Pattern
Cloud Storage upload event
|
v
Pub/Sub topic
|
v
Cloud Functions (image processing)
|
v
Firestore (metadata storage)
API-First Pattern
Cloud Endpoints or API Gateway
|
v
Cloud Run (multiple services)
|
├── Cloud SQL (transactional data)
└── Firestore (user data)
Microservices on GKE
GKE with Service Mesh
Global Load Balancer
|
v
GKE Ingress
|
v
Anthos Service Mesh (Istio)
|
v
Microservices (Cloud Spanner, Firestore, Memorystore)
Data Analytics Platform
Data Sources
|
v
Pub/Sub (streaming)
|
v
Dataflow (Apache Beam)
|
v
BigQuery (data warehouse)
|
v
Looker or Data Studio (visualization)
Batch Processing
Cloud Storage (raw data)
|
v
Dataproc (Apache Spark)
|
v
BigQuery (analytics)
Landing Zone Design
Resource Hierarchy
Organization
├── Folders (by environment or team)
│ ├── Production Folder
│ │ ├── Project A
│ │ └── Project B
│ ├── Staging Folder
│ └── Development Folder
└── Shared Services Folder
├── Networking Project (Shared VPC host)
├── Security Project (KMS, Secret Manager)
└── Logging Project (centralized logs)
Network Design
Shared VPC Pattern
Host Project (networking team)
├── Shared VPC
│ ├── Subnet Production (region A)
│ ├── Subnet Staging (region A)
│ └── Subnet Development (region B)
Service Projects (application teams)
├── Production Project (uses Production subnet)
├── Staging Project (uses Staging subnet)
└── Development Project (uses Development subnet)
Hub-and-Spoke with VPN
On-premises Network
|
v
Cloud VPN / Interconnect
|
v
Hub VPC (shared services)
|
├── Spoke VPC 1 (production workloads)
├── Spoke VPC 2 (development workloads)
└── Spoke VPC 3 (analytics workloads)
Governance
Organization Policies
- Restrict public IP assignment
- Enforce uniform bucket-level access
- Restrict VM external IP
- Define allowed resource locations
IAM Strategy
- Use Google Groups for role assignments
- Separate duties (network admin, security admin, etc.)
- Service accounts per application
- Workload Identity for GKE workloads
Logging and Monitoring
All Projects
|
v
Log Router
|
├── Cloud Logging (default sink)
├── BigQuery (long-term analysis)
├── Cloud Storage (archive)
└── Pub/Sub (real-time processing)
Migration Strategies
Migrate to Virtual Machines
Tools
- Migrate to Virtual Machines (formerly Migrate for Compute Engine)
- Supports VMware, AWS, Azure, physical servers
- Agentless or agent-based migration
- Waves and test clones
Process
- Assess: Fit assessment and TCO analysis
- Plan: Group VMs, define migration waves
- Deploy: Set up infrastructure (VPC, firewall rules)
- Migrate: Test migration, cutover, validation
- Optimize: Right-sizing, committed use discounts
Database Migration
Database Migration Service
- Minimal downtime migrations
- Supports MySQL, PostgreSQL, SQL Server, Oracle
- Continuous replication for cutover flexibility
Transfer Appliance
- Physical device for large data transfers
- Up to 1 PB capacity
- Offline data transfer
Cost Optimization
Compute Savings
Committed Use Discounts
- 1-year or 3-year commitments
- Up to 57% savings for VMs
- Resource-based or spend-based
Sustained Use Discounts
- Automatic discounts for running VMs >25% of month
- Up to 30% savings
- No commitment required
Preemptible and Spot VMs
- Up to 80% discount
- Can be terminated by GCP
- Best for batch processing, fault-tolerant workloads
Recommender
- VM rightsizing recommendations
- Idle resource identification
- Committed use discount recommendations
Storage Savings
Cloud Storage
- Autoclass for automatic tier transitions
- Lifecycle policies (delete or transition)
- Nearline (30+ days), Coldline (90+ days), Archive (365+ days)
- Requester pays for data transfer
Persistent Disk
- Delete orphaned disks
- Use balanced SSD instead of SSD when possible
- Resize disks to match actual usage
BigQuery Savings
On-Demand Pricing
- $5 per TB processed
- Use partitioning and clustering
- Query cache for free repeated queries
Flat-Rate Pricing
- Predictable costs for heavy users
- Autoscaling slots available
- Flex slots for short-term commitments
Best Practices
- Use approximate aggregation functions (APPROX_COUNT_DISTINCT)
- Avoid SELECT *, specify columns
- Use materialized views for common queries
- Set up cost controls with custom quotas
Monitoring Costs
Cloud Billing
- Budgets and alerts
- Cost breakdown by project, service, SKU
- Export to BigQuery for analysis
- Recommendations from Active Assist
Disaster Recovery
Backup Strategies
VM Backups
- Persistent disk snapshots (incremental)
- Machine images (include metadata and config)
- Cross-region snapshot copy
- Snapshot schedules for automation
Database Backups
- Cloud SQL: Automated backups (7-365 days retention)
- Cloud Spanner: Backups on demand or scheduled
- Firestore: Automated daily exports
- Bigtable: Backups to Cloud Storage
High Availability
RTO/RPO Matrix
| Pattern |
RPO |
RTO |
Cost |
| Active-Active Multi-Region |
Seconds |
Seconds |
High |
| Active-Passive with Replication |
Minutes |
Minutes |
Medium |
| Warm Standby |
Minutes |
10-30 min |
Medium |
| Backup and Restore |
Hours |
Hours |
Low |
Cloud SQL HA
- Regional configuration with synchronous replication
- Automatic failover
- 99.95% SLA (vs 99.5% for single zone)
Cloud Spanner
- Multi-region configuration
- 99.999% availability SLA
- Synchronous replication across regions
Disaster Recovery Testing
- Regular DR drills (quarterly recommended)
- Document runbooks
- Test restoration procedures
- Measure actual RTO/RPO vs targets
Monitoring and Observability
Cloud Monitoring (formerly Stackdriver)
Metrics
- System metrics (CPU, memory, disk, network)
- Custom metrics via Cloud Monitoring API
- Metric scopes for multi-project monitoring
- Uptime checks for availability
Dashboards and Charts
- Predefined dashboards for GCP services
- Custom dashboards with filters and grouping
- SLO monitoring with error budgets
Cloud Logging
Log Types
- Admin Activity logs (always enabled, no charge)
- Data Access logs (must be enabled)
- System Event logs
- Access Transparency logs (for Google access)
Log Sinks
- Route logs to BigQuery, Cloud Storage, Pub/Sub
- Aggregated sinks at organization/folder level
- Exclusion filters to reduce costs
Cloud Trace
Distributed Tracing
- Automatic instrumentation for App Engine, Cloud Run, GKE
- Manual instrumentation with client libraries
- Latency analysis and performance insights
- Integration with Zipkin
Cloud Profiler
Continuous Profiling
- CPU and memory profiling
- Low overhead (< 0.5% CPU)
- Flame graphs for visualization
- Supported languages: Java, Go, Python, Node.js
Error Reporting
Aggregated Error Tracking
- Automatic error grouping
- Stack trace analysis
- Integration with Cloud Logging
- Notifications for new errors
1---2name: 401-gcp-963b2cc43description: GCP Architecture Reference4---5# GCP Architecture Reference67Comprehensive guide for Google Cloud Platform services, patterns, and architecture framework.89## Google Cloud Architecture Framework1011### Five Pillars12131. **Operational Excellence**14 - Infrastructure as Code (Deployment Manager, Terraform)15 - CI/CD with Cloud Build16 - Monitoring with Cloud Monitoring (Stackdriver)17 - SRE principles and SLOs18 - Incident management19202. **Security, Privacy, and Compliance**21 - Identity and Access Management (Cloud IAM)22 - VPC Service Controls for data perimeter23 - Binary Authorization for containers24 - Data encryption (default at rest and in transit)25 - Security Command Center26273. **Reliability**28 - Multi-zone and multi-region deployments29 - Load balancing and autoscaling30 - Disaster recovery planning31 - Chaos engineering practices32 - SLIs, SLOs, and error budgets33344. **Cost Optimization**35 - Committed Use Discounts36 - Sustained Use Discounts (automatic)37 - Preemptible VMs and Spot VMs38 - Recommender for right-sizing39 - Active Assist for optimization40415. **Performance Optimization**42 - Cloud CDN and Media CDN43 - Caching strategies (Memorystore)44 - Database performance tuning45 - Network optimization (Premium vs Standard tier)46 - Regional and zonal resource placement4748## Core Services Architecture4950### Compute5152**Compute Engine**53- Machine types: E2 (cost-optimized), N2 (balanced), C2 (compute-optimized), M2 (memory-optimized)54- Custom machine types for specific needs55- Preemptible VMs (up to 80% discount, max 24 hours)56- Spot VMs (similar to preemptible, better availability)57- Instance groups: Managed (with autoscaling), unmanaged58- Best practices: Use latest generation, committed use discounts, Spot for batch jobs5960**Cloud Run**61- Fully managed serverless container platform62- Auto-scaling to zero63- Pay per request64- CPU allocated only during request handling65- Best practices: Stateless containers, optimize cold starts, use Cloud Run jobs for batch6667**Cloud Functions**68- Event-driven serverless functions69- 1st gen: HTTP and background functions70- 2nd gen: Built on Cloud Run, better performance71- Event sources: Pub/Sub, Cloud Storage, Firestore, HTTP72- Best practices: Use 2nd gen, minimize cold starts, implement retry logic7374**Google Kubernetes Engine (GKE)**75- Managed Kubernetes with GCP integration76- Autopilot mode: Fully managed, per-pod pricing77- Standard mode: More control, node management78- Workload Identity for secure service access79- Binary Authorization for deployment policies80- Best practices: Use Autopilot for simplicity, enable Workload Identity, implement network policies8182**App Engine**83- Fully managed platform (PaaS)84- Standard environment (sandboxed, auto-scaling)85- Flexible environment (Docker containers, custom runtimes)86- Traffic splitting for canary deployments87- Best practices: Use Standard for web apps, Flexible for custom dependencies8889### Storage9091**Cloud Storage**92- Storage classes: Standard, Nearline (30-day), Coldline (90-day), Archive (365-day)93- Object lifecycle management94- Object versioning and retention policies95- Autoclass for automatic tier transitions96- Requester pays for data transfer97- Best practices: Use Autoclass, enable versioning, implement lifecycle policies9899**Persistent Disk**100- Types: Standard (HDD), Balanced SSD, SSD, Extreme101- Zonal and regional persistent disks102- Snapshots for backup (incremental)103- Disk resize without downtime104- Best practices: Use Balanced SSD for most workloads, enable snapshots105106**Filestore**107- Managed NFS file storage108- Tiers: Basic (1-63.9 TB), Enterprise (1-10 TB, better performance)109- Backup to Cloud Storage110- Best practices: Use Enterprise for production, implement backups111112**Cloud Storage for Firebase**113- Object storage for mobile and web apps114- Client SDKs for direct upload/download115- Security rules for access control116117### Database118119**Cloud SQL**120- Managed MySQL, PostgreSQL, SQL Server121- High availability configuration (regional)122- Read replicas for scaling123- Automated backups and point-in-time recovery124- Best practices: Enable HA, use read replicas, implement connection pooling with Cloud SQL Proxy125126**Cloud Spanner**127- Globally distributed relational database128- Horizontal scalability with strong consistency129- Multi-region for 99.999% availability130- TrueTime for global consistency131- Best practices: Design proper schema splits, use commit timestamps, optimize hotspots132133**Firestore (Native mode)**134- NoSQL document database135- Real-time synchronization136- Offline support for mobile137- ACID transactions138- Best practices: Design document structure carefully, use collection group queries wisely139140**Bigtable**141- NoSQL wide-column database142- Petabyte-scale with single-digit millisecond latency143- HBase API compatible144- Linear scalability by adding nodes145- Best practices: Design row keys to avoid hotspots, use replication for HA146147**Memorystore**148- Managed Redis and Memcached149- Standard tier (HA with replica) and Basic tier150- Best practices: Use Standard tier for production, implement connection pooling151152**BigQuery**153- Serverless data warehouse154- SQL analytics on petabyte-scale data155- Column-oriented storage156- Automatic caching and optimization157- Best practices: Partition and cluster tables, use approximate functions, control costs with quotas158159### Networking160161**VPC (Virtual Private Cloud)**162- Global resource (subnets are regional)163- Custom or auto mode networks164- Firewall rules (stateful)165- VPC peering and Shared VPC166- Private Google Access for GCP services167- Best practices: Use custom mode VPC, plan IP ranges, implement firewall rules168169**Cloud Load Balancing**170- Global load balancing (HTTP(S), TCP/SSL Proxy, external TCP/UDP)171- Regional load balancing (internal HTTP(S), internal TCP/UDP)172- Anycast IP for global distribution173- Backend services with health checks174- Best practices: Use global for multi-region, enable CDN, configure health checks175176**Cloud CDN**177- Global content delivery network178- Cache invalidation and signed URLs179- Integration with Cloud Storage and compute180- Best practices: Enable compression, use cache-control headers181182**Cloud Interconnect and VPN**183- Dedicated Interconnect (10 Gbps or 100 Gbps)184- Partner Interconnect (50 Mbps to 50 Gbps)185- Cloud VPN (HA VPN for 99.99% SLA)186- Best practices: Use HA VPN for redundancy, Dedicated Interconnect for high bandwidth187188**Cloud Armor**189- DDoS protection and WAF190- Preconfigured and custom rules191- Adaptive protection (ML-based)192- Best practices: Enable for internet-facing services, use preconfigured rules193194**Private Service Connect**195- Private connectivity to Google APIs and services196- Service Directory for service discovery197- Best practices: Use for all managed services in production198199### Serverless and Event-Driven200201**Pub/Sub**202- Global message queue203- At-least-once delivery204- Push and pull subscriptions205- Message ordering and filtering206- Dead-letter topics207- Best practices: Use message attributes for filtering, implement idempotent processing208209**Eventarc**210- Event-driven architecture211- Triggers for Cloud Run, Workflows, GKE212- Sources: Audit Logs, Pub/Sub, custom events213- Best practices: Use for decoupled architectures, implement event filtering214215**Cloud Scheduler**216- Fully managed cron service217- HTTP, Pub/Sub, and App Engine targets218- Best practices: Use for periodic tasks, implement retry logic219220**Workflows**221- Orchestrate and automate GCP and HTTP services222- YAML-based workflow definition223- Built-in error handling and retry224- Best practices: Use for complex multi-step processes, implement compensating transactions225226### Security and Identity227228**Cloud IAM**229- Resource hierarchy: Organization -> Folders -> Projects -> Resources230- Roles: Primitive (Owner, Editor, Viewer), Predefined, Custom231- Service accounts for applications232- Workload Identity for GKE233- Best practices: Use predefined roles, least privilege, service accounts for apps234235**Cloud Key Management (KMS)**236- Encryption key management237- Customer-managed encryption keys (CMEK)238- Hardware Security Module (HSM) backed239- Automatic key rotation240- Best practices: Enable automatic rotation, use separate keys per environment241242**Secret Manager**243- Store API keys, passwords, certificates244- Versioning and access control245- Automatic rotation integration246- Best practices: Rotate secrets regularly, use IAM for access control247248**Security Command Center**249- Centralized security and risk management250- Asset discovery and vulnerability scanning251- Threat detection and compliance monitoring252- Best practices: Enable all detectors, review findings regularly253254**VPC Service Controls**255- Create security perimeters around GCP resources256- Prevent data exfiltration257- Best practices: Use for sensitive data, implement access levels258259### AI and Machine Learning260261**Vertex AI**262- Unified ML platform263- AutoML for custom models264- Pre-trained models (Vision, Natural Language, etc.)265- MLOps with pipelines266- Best practices: Use AutoML for quick start, implement feature store267268**BigQuery ML**269- Create and execute ML models using SQL270- Model types: Linear regression, logistic regression, clustering, etc.271- Integration with Vertex AI272- Best practices: Use for simple models, leverage BigQuery's scale273274## Architecture Patterns275276### High Availability277278**Multi-Zone Pattern**279```280Global HTTP(S) Load Balancer281 |282 v283Managed Instance Group (multi-zone)284 |285 v286Cloud SQL (regional, HA configuration)287 |288 v289Cloud Storage (multi-region)290```291292**Multi-Region Pattern**293```294Global HTTP(S) Load Balancer295 |296 ├── Backend Service Region 1 (Cloud Run)297 └── Backend Service Region 2 (Cloud Run)298 |299 v300 Cloud Spanner (multi-region)301```302303### Serverless Architecture304305**Event-Driven Pattern**306```307Cloud Storage upload event308 |309 v310Pub/Sub topic311 |312 v313Cloud Functions (image processing)314 |315 v316Firestore (metadata storage)317```318319**API-First Pattern**320```321Cloud Endpoints or API Gateway322 |323 v324Cloud Run (multiple services)325 |326 ├── Cloud SQL (transactional data)327 └── Firestore (user data)328```329330### Microservices on GKE331332**GKE with Service Mesh**333```334Global Load Balancer335 |336 v337GKE Ingress338 |339 v340Anthos Service Mesh (Istio)341 |342 v343Microservices (Cloud Spanner, Firestore, Memorystore)344```345346### Data Analytics Platform347348```349Data Sources350 |351 v352Pub/Sub (streaming)353 |354 v355Dataflow (Apache Beam)356 |357 v358BigQuery (data warehouse)359 |360 v361Looker or Data Studio (visualization)362```363364**Batch Processing**365```366Cloud Storage (raw data)367 |368 v369Dataproc (Apache Spark)370 |371 v372BigQuery (analytics)373```374375## Landing Zone Design376377### Resource Hierarchy378379```380Organization381├── Folders (by environment or team)382│ ├── Production Folder383│ │ ├── Project A384│ │ └── Project B385│ ├── Staging Folder386│ └── Development Folder387└── Shared Services Folder388 ├── Networking Project (Shared VPC host)389 ├── Security Project (KMS, Secret Manager)390 └── Logging Project (centralized logs)391```392393### Network Design394395**Shared VPC Pattern**396```397Host Project (networking team)398├── Shared VPC399│ ├── Subnet Production (region A)400│ ├── Subnet Staging (region A)401│ └── Subnet Development (region B)402403Service Projects (application teams)404├── Production Project (uses Production subnet)405├── Staging Project (uses Staging subnet)406└── Development Project (uses Development subnet)407```408409**Hub-and-Spoke with VPN**410```411On-premises Network412 |413 v414Cloud VPN / Interconnect415 |416 v417Hub VPC (shared services)418 |419 ├── Spoke VPC 1 (production workloads)420 ├── Spoke VPC 2 (development workloads)421 └── Spoke VPC 3 (analytics workloads)422```423424### Governance425426**Organization Policies**427- Restrict public IP assignment428- Enforce uniform bucket-level access429- Restrict VM external IP430- Define allowed resource locations431432**IAM Strategy**433- Use Google Groups for role assignments434- Separate duties (network admin, security admin, etc.)435- Service accounts per application436- Workload Identity for GKE workloads437438**Logging and Monitoring**439```440All Projects441 |442 v443Log Router444 |445 ├── Cloud Logging (default sink)446 ├── BigQuery (long-term analysis)447 ├── Cloud Storage (archive)448 └── Pub/Sub (real-time processing)449```450451## Migration Strategies452453### Migrate to Virtual Machines454455**Tools**456- Migrate to Virtual Machines (formerly Migrate for Compute Engine)457- Supports VMware, AWS, Azure, physical servers458- Agentless or agent-based migration459- Waves and test clones460461**Process**4621. Assess: Fit assessment and TCO analysis4632. Plan: Group VMs, define migration waves4643. Deploy: Set up infrastructure (VPC, firewall rules)4654. Migrate: Test migration, cutover, validation4665. Optimize: Right-sizing, committed use discounts467468### Database Migration469470**Database Migration Service**471- Minimal downtime migrations472- Supports MySQL, PostgreSQL, SQL Server, Oracle473- Continuous replication for cutover flexibility474475**Transfer Appliance**476- Physical device for large data transfers477- Up to 1 PB capacity478- Offline data transfer479480## Cost Optimization481482### Compute Savings483484**Committed Use Discounts**485- 1-year or 3-year commitments486- Up to 57% savings for VMs487- Resource-based or spend-based488489**Sustained Use Discounts**490- Automatic discounts for running VMs >25% of month491- Up to 30% savings492- No commitment required493494**Preemptible and Spot VMs**495- Up to 80% discount496- Can be terminated by GCP497- Best for batch processing, fault-tolerant workloads498499**Recommender**500- VM rightsizing recommendations501- Idle resource identification502- Committed use discount recommendations503504### Storage Savings505506**Cloud Storage**507- Autoclass for automatic tier transitions508- Lifecycle policies (delete or transition)509- Nearline (30+ days), Coldline (90+ days), Archive (365+ days)510- Requester pays for data transfer511512**Persistent Disk**513- Delete orphaned disks514- Use balanced SSD instead of SSD when possible515- Resize disks to match actual usage516517### BigQuery Savings518519**On-Demand Pricing**520- $5 per TB processed521- Use partitioning and clustering522- Query cache for free repeated queries523524**Flat-Rate Pricing**525- Predictable costs for heavy users526- Autoscaling slots available527- Flex slots for short-term commitments528529**Best Practices**530- Use approximate aggregation functions (APPROX_COUNT_DISTINCT)531- Avoid SELECT *, specify columns532- Use materialized views for common queries533- Set up cost controls with custom quotas534535### Monitoring Costs536537**Cloud Billing**538- Budgets and alerts539- Cost breakdown by project, service, SKU540- Export to BigQuery for analysis541- Recommendations from Active Assist542543## Disaster Recovery544545### Backup Strategies546547**VM Backups**548- Persistent disk snapshots (incremental)549- Machine images (include metadata and config)550- Cross-region snapshot copy551- Snapshot schedules for automation552553**Database Backups**554- Cloud SQL: Automated backups (7-365 days retention)555- Cloud Spanner: Backups on demand or scheduled556- Firestore: Automated daily exports557- Bigtable: Backups to Cloud Storage558559### High Availability560561**RTO/RPO Matrix**562563| Pattern | RPO | RTO | Cost |564|---------|-----|-----|------|565| Active-Active Multi-Region | Seconds | Seconds | High |566| Active-Passive with Replication | Minutes | Minutes | Medium |567| Warm Standby | Minutes | 10-30 min | Medium |568| Backup and Restore | Hours | Hours | Low |569570**Cloud SQL HA**571- Regional configuration with synchronous replication572- Automatic failover573- 99.95% SLA (vs 99.5% for single zone)574575**Cloud Spanner**576- Multi-region configuration577- 99.999% availability SLA578- Synchronous replication across regions579580### Disaster Recovery Testing581582- Regular DR drills (quarterly recommended)583- Document runbooks584- Test restoration procedures585- Measure actual RTO/RPO vs targets586587## Monitoring and Observability588589### Cloud Monitoring (formerly Stackdriver)590591**Metrics**592- System metrics (CPU, memory, disk, network)593- Custom metrics via Cloud Monitoring API594- Metric scopes for multi-project monitoring595- Uptime checks for availability596597**Dashboards and Charts**598- Predefined dashboards for GCP services599- Custom dashboards with filters and grouping600- SLO monitoring with error budgets601602### Cloud Logging603604**Log Types**605- Admin Activity logs (always enabled, no charge)606- Data Access logs (must be enabled)607- System Event logs608- Access Transparency logs (for Google access)609610**Log Sinks**611- Route logs to BigQuery, Cloud Storage, Pub/Sub612- Aggregated sinks at organization/folder level613- Exclusion filters to reduce costs614615### Cloud Trace616617**Distributed Tracing**618- Automatic instrumentation for App Engine, Cloud Run, GKE619- Manual instrumentation with client libraries620- Latency analysis and performance insights621- Integration with Zipkin622623### Cloud Profiler624625**Continuous Profiling**626- CPU and memory profiling627- Low overhead (< 0.5% CPU)628- Flame graphs for visualization629- Supported languages: Java, Go, Python, Node.js630631### Error Reporting632633**Aggregated Error Tracking**634- Automatic error grouping635- Stack trace analysis636- Integration with Cloud Logging637- Notifications for new errors