What is Cloud SQL?
Priyanka Vergadia
Staff Developer Advocate, Google Cloud
Gabe Weiss
Developer Advocate
If you are building an application, chances are you will need a relational database for transaction processing. That’s where Cloud SQL comes in. It is a fully managed relational database for MySQL, PostgreSQL and SQL Server. It reduces maintenance cost and automates database provisioning, storage capacity management, backups and out of the box High availability and Disaster recovery/failover.
How to set up Cloud SQL?
Cloud SQL is easy to set up.
- You select the region and zone where you would like the instance to be and they get created.
- Configure the machine type with the right number of CPU & amount of memory your application needs
- Choose storage type between solid state and hard disk drives depending on latency, QPS and cost requirements.
Reliability & Availability
Cloud SQL also offers automated backups and point-in-time recovery options. You can set time slots and locations for backups. For production applications it is recommended to enable built-in high availability (HA) option which supports 99.95% SLA. With this, Google Cloud continuously monitors the Cloud SQL instance with a heartbeat signal and when a master fails an automatic failover is triggered to another zone in your selected region in case of an outage. You can also create replicas across regions to protect from regional failure. And, you can enable automatic storage increase to add more storage when nearing capacity.
Cloud SQL Insights, a free tool, helps detect, diagnose, and identify problems in a query for Cloud SQL databases. It provides self-service, intuitive monitoring, and diagnostic information that goes beyond detection to help you to identify the root cause of performance problems.
How to migrate an existing MySQL database to Cloud SQL?
If you have an existing application that you are moving to cloud then chances are that you need to migrate your existing SQL database to Cloud SQL. Database Migration Service(DMS) simplifies migration of MySQL and PostgreSQL databases from on-premises, Google Compute Engine, and other clouds to Cloud SQL. It is serverless, easy to set up and available at no additional cost. It replicates data continuously for minimal downtime migrations.
Here’s how it works:
- Provide your data source details - type of database engine MySQL, PostgreSQL, Amazon RDS or others. Pick one time or continuous replication for minimal downtime.
- Create a Cloud SQL instance as your destination.
- For connectivity to the source instance DMS makes it easy by providing multiple options. You can allow-list an IP address, create a reverse SSH tunnel via cloud hosted Virtual Machine or set up VPC peering.
- Finally test and promote the migrated instance to primary Cloud SQL instance.
Security & Compliance
The data in CloudSQL is automatically encrypted at rest and in transit. External connections can be enforced to be SSL-only. For secure connectivity you can also use Cloud SQL Proxy which is a tool to help you connect to your Cloud SQL instance from your local machine. You can control network access with firewall protection. From the compliance perspective Cloud SQL is SSAE 16, ISO 27001, PCI DSS v3.0, and HIPAA compliant.
Cloud SQL in action
Cloud SQL can be used in multiple use cases in conjunction with different compute options. You can use it in any application as a transactional database, long-term analytics backend with BigQuery, predictive analytics with Vertex AI and event driven messaging with Pub/Sub. Cloud SQL when combined with Datasteam (Change Data Capture) makes a great real-time analysis solution for any incoming data. Here are a few examples
Conclusion
Whatever your application use case may be, Cloud SQL is designed to integrate with different services within and outside Google Cloud. Use this fully managed relational database and let Google take care of the endless maintenance required to run a database including setting up servers, applying patches and updates, configuring replication and managing backups. Instead, focus your energy on higher priority work where you can really add value. For a more in-depth look into Cloud SQL check out the documentation.
For more #GCPSketchnote, follow the GitHub repo. For similar cloud content follow me on Twitter @pvergadia and keep an eye out on thecloudgirl.dev