Cloud SQL Study Notes
Cloud SQL is a fully managed relational database service for MySQL, PostgreSQL, and SQL Server that handles backups, patching, replication, and failover. It is the default choice for traditional applications needing a familiar relational database without managing the underlying VM. Cloud SQL scales vertically easily and offers read replicas for read scaling within and across regions.
Key facts
- Cloud SQL automates database maintenance tasks such as backups, software patching, monitoring, and storage increases, while you still configure machine type, storage, and maintenance windows.
- High availability is provided by a regional configuration with a primary instance and a standby in another zone, with automatic failover that changes the instance IP handling transparently for connected applications using the correct connector.
- Read replicas can be created in the same region or in other regions to offload read traffic and support analytics or disaster recovery, but replicas are read-only and replicate asynchronously in most configurations.
- Automated backups run daily by default at the time of writing, and point-in-time recovery using binary or write-ahead logs lets you restore to a specific moment before an error or deletion.
- The Cloud SQL Auth Proxy and Cloud SQL connectors provide secure, encrypted connections without managing SSL certificates or adding authorized networks for every client IP address.
- Private connectivity through Private Service Connect or private IP in a VPC is the secure production pattern, avoiding exposure of the database on a public IP address.
- Storage can be configured to increase automatically as it fills, and machine resources can be resized, but scaling is primarily vertical rather than the horizontal sharding offered by distributed databases.
- Cloud SQL supports importing and exporting data using SQL dump files and CSV files stored in Cloud Storage, which is useful for small migrations and seeding environments.
- Maintenance can cause brief downtime, and you can set a preferred maintenance window and deny periods to avoid updates during critical business events.
What the exam expects you to know
- Pick Cloud SQL for lift-and-shift relational workloads using MySQL, PostgreSQL, or SQL Server that need managed backups and failover without operational overhead.
- Use read replicas to scale reads and place a replica in another region for reporting or disaster recovery, remembering replication is asynchronous and may lag.
- Recommend the Cloud SQL Auth Proxy or connectors when a question asks for secure connectivity without whitelisting IPs or manually managing certificates.
- Know that high availability is zonal redundancy within a region, not multi-region active-active writes, which would require Spanner or another distributed solution.
- Choose point-in-time recovery to restore after accidental data corruption, and understand that restoring creates a new instance rather than overwriting in place.
- Identify Database Migration Service as the tool for minimal-downtime migration into Cloud SQL, rather than a simple dump and load for production cutovers.
Cloud SQL vs Cloud Spanner: when to use which
Use Cloud SQL when your application needs a conventional relational database with strong consistency in a single region, familiar MySQL or PostgreSQL compatibility, and modest vertical scaling. Use Cloud Spanner when you need global distribution, horizontal scaling to very large write throughput, and multi-region strong consistency with automatic sharding. The exam distinction is scale and geography: a regional business application fits Cloud SQL, while a global inventory or financial system needing unlimited scale and five-nines availability fits Spanner. Cloud SQL is also cheaper and simpler for most standard workloads. See also the Cloud Spanner notes.
Useful gcloud commands
gcloud sql instances create my-instance --database-version=POSTGRES_15 --region=us-central1 --root-password=CHANGE_ME
gcloud sql instances patch my-instance --assign-ip --network=default
gcloud sql backups create --instance=my-instance
gcloud sql instances create my-replica --master-instance-name=my-instance --region=europe-west1Common exam traps
- Read replicas are not writable and do not provide automatic failover in the same way a high availability standby does; promoting a replica is a manual disaster recovery step.
- Cloud SQL does not scale writes horizontally across many nodes; assuming it behaves like Spanner for global write scale is a common misconception.
- Adding authorized networks for a public IP is insecure compared to private IP or the Auth Proxy, and exam scenarios about security expect the private option.
- Restoring a backup creates a new instance with a new configuration to verify, it does not roll back the original instance in place without downtime.
Frequently asked questions
How does Cloud SQL high availability work?
In a regional high availability configuration, Cloud SQL maintains a standby instance in a different zone with synchronous replication from the primary. If the primary zone fails, automatic failover promotes the standby and traffic is redirected, minimizing downtime. This protects against zonal failures but not an entire region outage, which needs cross-region replicas and promotion planning.
What is the Cloud SQL Auth Proxy used for?
The Cloud SQL Auth Proxy creates a secure local connection to your Cloud SQL instance using IAM authentication and encrypted tunnels, without requiring authorized networks or manual SSL management. Applications connect to a local port as if the database were nearby. The exam favors the proxy or official connectors whenever secure, simplified connectivity is required.
Can Cloud SQL handle global writes?
No, Cloud SQL is designed for a primary instance in one region with read replicas elsewhere, so writes go to a single primary and cross-region write latency is not optimized. For globally distributed writes with strong consistency and horizontal scaling, Google recommends Cloud Spanner. Recognizing this limit is a frequent exam decision point for architecture questions.
Study aid disclaimer: Cloud Cert Notes is an independent educational study aid. It is not affiliated with, endorsed by, or sponsored by Google, Microsoft, Amazon, Oracle, or Alibaba. Google Cloud, Associate Cloud Engineer, and Cloud Digital Leader are trademarks of Google LLC; all other certification names and product names are trademarks of their respective owners. Always confirm service details against the official provider documentation before sitting an exam.