Relational Databases on GCP: Cloud SQL, AlloyDB, High Availability, Read Replicas and Backups
Managed Relational Databases
A relational database stores data in tables and uses SQL. Managed means Google handles patching, backups, replication and failover, and you handle schema, queries, access and sizing.
Cloud SQL
- Supports MySQL, PostgreSQL and SQL Server
- Vertical scaling by changing the machine size and storage (storage can auto-increase)
- Editions: Enterprise and Enterprise Plus (higher performance, availability and maintenance downtime near zero)
- Good for web apps, CMS, small to medium transactional systems (up to a few TB)
bash
gcloud sql instances create shop-db --database-version=POSTGRES_16 --edition=ENTERPRISE --tier=db-custom-2-8192 --region=asia-south1 \
--availability-type=REGIONAL --storage-size=100GB --storage-auto-increase --backup-start-time=21:00 --enable-point-in-time-recovery \
--network=projects/my-proj/global/networks/prod-vpc --no-assign-ip
gcloud sql databases create shopdb --instance=shop-db
gcloud sql users create appuser --instance=shop-db --password=CHANGE-ME
High Availability and Replicas
| Feature | Purpose | Notes |
|---|---|---|
| HA (regional) configuration | Standby in another zone. Automatic failover (about a minute or two) | Synchronous replication. Not for read scaling |
| Read replica | Offload reads, reporting | Asynchronous. Can be cross-region. Can be promoted for disaster recovery |
| Cascading replicas | Replica of a replica | For many readers |
| Cross-region DR replica | Recover from a regional outage | Promote it, then repoint apps |
Backups and Recovery
- Automated backups (daily window, retention up to 365 days) and on-demand backups
- Point-in-time recovery (PITR) replays logs to any second in the retention window. Restore creates a new instance
- Export to Cloud Storage as SQL or CSV for archives and migration
bash
gcloud sql backups create --instance=shop-db
gcloud sql instances clone shop-db shop-db-restore --point-in-time=2026-11-17T08:30:00Z
gcloud sql export sql shop-db gs://acme-backups/shopdb.sql --database=shopdb
gcloud sql instances failover shop-db # test HA failover
Connecting Safely
- Use private IP (private services access or Private Service Connect). Avoid public IP
- Use the Cloud SQL Auth Proxy or language connectors for encrypted, IAM-authenticated connections
- Enable IAM database authentication where supported
- Store passwords in Secret Manager
- Use connection pooling (PgBouncer) for many short connections, for example from Cloud Run
bash
./cloud-sql-proxy --private-ip my-proj:asia-south1:shop-db &
psql "host=127.0.0.1 user=appuser dbname=shopdb"
Maintenance
- Set a maintenance window and deny periods (for busy sales days)
- Choose Enterprise Plus for near-zero downtime maintenance
AlloyDB for PostgreSQL
- Google's PostgreSQL-compatible database with a disaggregated storage layer, built for high performance (much faster for transactions and analytics queries than standard PostgreSQL, according to Google)
- Features: columnar engine for analytic queries, read pools, 99.99 percent availability SLA with HA, built-in AI features such as vector search and model integration
- Choose when you outgrow Cloud SQL PostgreSQL or want one database for transactions and real-time analytics
Cloud SQL or AlloyDB or Spanner?
| Need | Choose |
|---|---|
| MySQL or SQL Server, simple, low cost | Cloud SQL |
| PostgreSQL, standard workload | Cloud SQL for PostgreSQL |
| PostgreSQL with very high performance, HTAP, vectors | AlloyDB |
| Relational with global scale and horizontal writes | Spanner |
| Oracle workloads | Bare Metal Solution or migrate |
Practice
- Create a regional Cloud SQL PostgreSQL instance with private IP
- Connect with the Auth Proxy and create a table
- Add a read replica and send read queries to it
- Clone the instance to a point in time
- Delete the instances when finished
Conclusion
Cloud SQL provides managed MySQL, PostgreSQL and SQL Server with HA, replicas, backups and PITR. Use private IP and the Auth Proxy for safe access. AlloyDB is the high-performance PostgreSQL option, and Spanner is for global scale.
Quick Summary: managed; Cloud SQL; HA; backups; connecting; maintenance; AlloyDB; choosing.

