Exams / GCP-PCDBE / D1 Deploy scalable and highly available databases in Google Cloud
D1.1
Deploy scalable and highly available databases in Google Cloud
- Exam domain: Deploy scalable and highly available databases in Google Cloud
You are reading a free preview. The rest of the GCP-PCDBE course unlocks with an Exam pass or All access.See plans
Cloud SQL high availability and replicas
| Feature | Replication | Purpose |
|---|---|---|
| HA standby (regional instance) | Synchronous, regional persistent disk across two zones | Zonal failover, no data loss |
| Read replica (same region) | Asynchronous | Offload reads; put in a third zone |
| Cross-region replica | Asynchronous (lag = possible loss) | Disaster recovery, promote |
- HA needs automated backups and point-in-time recovery (not on read replicas). The standby cannot serve reads.
- Enable HA in place:
gcloud sql instances patch INSTANCE --availability-type REGIONAL. HA can also be enabled on a read replica. - Test with
gcloud sql instances failover PRIMARY. - SQL Server cross-region replicas: check status with the Always On Availability Group dashboard in SSMS.
- Place primary, standby and read replica in three different zones.
Maintenance and protection
- Maintenance window = one hour; a deny maintenance period (up to 90 days) takes precedence. Example: Sundays 12-1 AM, deny Nov 1 - Jan 15.
- Enterprise Plus edition gives near-zero downtime for planned operations; HA alone does not.
- Deletion protection stops Terraform (or users) from dropping an instance.
- CMEK is set at instance creation; key in the same location.
Choosing and scaling databases
- Spanner: ACID, relational, 99.999% multi-region; Autoscaler linear = gradual growth, direct = immediate capacity.
- Spanner recovery: stale read at a timestamp for partial corruption; backup at timestamp and restore for whole-database.
- Bigtable: TB-PB, low latency, scale by nodes (IoT/time series).
- AlloyDB: continuous backup and recovery gives PITR (1-35 days); read pools scale by node count, manually or with autoscaling.
- Firestore: schedule exports with Cloud Scheduler + Cloud Function; bundles served from a CDN for shared content.
Bigtable failover
Multi-cluster routing in a custom app profile fails over automatically; single-cluster routing does not.
Access, monitoring, ops
| Need | Use |
|---|---|
| Passwordless AlloyDB | Language connector with automatic IAM authentication |
| Auth Proxy 403 Access Not Configured | Enable Cloud SQL Admin API |
| VM app to Cloud SQL | Service account with Cloud SQL Client |
| Read-only Spanner app | Dedicated service account, Database Reader role |
| Bottleneck diagnosis | System Insights (CPU, memory, disk, deadlocks); Query Insights; Cloud Trace for requests |
| CPU/memory SMS alerts | Cloud Monitoring alerting policy + notification channel |
| Fleet provisioning | Terraform |
Exam traps
- Cross-region replication is never synchronous.
- Deny period maximum 90 days; windows last one hour.
- HA does not remove maintenance downtime; Enterprise Plus does.
- Default Bigtable app profile is single-cluster; use a custom multi-cluster profile.
- Cloud SQL cannot give low-latency writes in several regions; Spanner can.
Docs
- https://docs.cloud.google.com/sql/docs/mysql/high-availability
- https://docs.cloud.google.com/sql/docs/mysql/configure-ha
- https://docs.cloud.google.com/sql/docs/mysql/replication/cross-region-replicas
- https://docs.cloud.google.com/sql/docs/mysql/maintenance
- https://docs.cloud.google.com/sql/docs/postgres/availability
- https://docs.cloud.google.com/spanner/docs/pitr
- https://docs.cloud.google.com/spanner/docs/autoscaler-tool-overview
- https://docs.cloud.google.com/bigtable/docs/managing-failovers
- https://cloud.google.com/alloydb/docs/backup/overview
- https://cloud.google.com/alloydb/docs/instance-read-pool-scale