GCP Data Engineer : Cloud SQL / Cloud Spanner
Overview
CloudSQL supports to store structured data and it comes under SQL category in GCP.
Use CloudSQL for below use-cases
Structured Data
Predefined Schemas
ACID Transactions
Strong Consistency
Tables, Partitions, Indexes, Views and Constraints
Login to cloud console, navigate to Database section and choose SQL
Supported Database Engines
CloudSQL right now supports
MySQL
PostgreSQL
SQLServer
Configuring Cloud SQL Instance
To launch a PostgreSQL instance, choose PostgreSQL and fill in Instance ID, Password and choose specific version to launch
Cloud SQL supports regional availability. Below screen helps to choose region and zones ( for highly available , pls choose Multiple Zones )
CloudSQL Machine types can be configured, based on the machine type, no of connections support may vary.
We have option to customize the machine type, by providing value for Cores and Memory as well.
Recommended by LinkedIn
Storage can be HDD or SSD. For better performance, choose SSD.Also we can specify the initial storage capacity for the instance and can enable the automatic storage increase option. This will help to dynamically increase the size, in case if the storage exceeds.
Encryption
GCP Storage supports Google -managed encryption key by default.
Connection Types
Connecting to the instance can be made public or it can be set to Private IP for security reasons.
For API development, best practice is to use Cloud SQL Proxy to connect with Service containers. Cloud SQL Proxy can be run as side-car container to enable service to connect to CloudSQL instance
Backups
CloudSQL backups data by choosing the option as below. Hence there will be a downtime, whereas in Cloud Spanner there will not be a downtime as its been managed by GCP
Cloud SQL Monitoring
Once the instance is launched, user can able to monitor the instance using below dashboard.
Metrics based on CPU Utilization, Memory Usage , Active connections will be captured here.
Cloud Spanner
In addition to the features supported by Cloud SQL, if you need High Availability ( Global, MultiRegional), Horizontal Scaling and Zero Downtime, go for Cloud Spanner
Login to cloud console, choose spanner option
Enable Spanner API and launch instance as below by choosing multi-regional ( for high availability ).
Spanner supports horizontal scaling ,zero downtime and automatic replication.
Happy Learning !
Bharathy Poovalingam
#GCP #CloudSQL#CloudSpanner #iGreenData #Learning
Well written, Bharathy !! Much needed