Prev Next

Cloud / Google Cloud SQL Interview questions

Last updated

1. What is Google Cloud SQL? 2. What are the database engines supported by Cloud SQL? 3. What are the editions available in Cloud SQL? 4. What is a Cloud SQL instance connection name? 5. What are the machine types available in Cloud SQL? 6. What is the purpose of automated backups in Cloud SQL? 7. What is a read replica in Cloud SQL? 8. How do you enable high availability for a Cloud SQL instance? 9. How do you create a Cloud SQL instance using gcloud? 10. What is the Cloud SQL Auth Proxy? 11. What are the ways to connect to a Cloud SQL instance? 12. What is a maintenance window in Cloud SQL? 13. What are database flags in Cloud SQL? 14. How do you import and export data in Cloud SQL? 15. What is Query Insights in Cloud SQL? 16. Define point-in-time recovery in Cloud SQL? 17. How do you stop and start a Cloud SQL instance? 18. What is Database Migration Service in Google Cloud? 19. What is the difference between Cloud SQL and a self-managed database on Compute Engine? 20. What is the difference between high availability and read replicas in Cloud SQL? 21. How does Cloud SQL high availability work? 22. What happens to applications during a Cloud SQL failover? 23. Why use private IP for Cloud SQL instances? 24. How does private services access work with Cloud SQL? 25. How is private services access different from Private Service Connect? 26. How does the Cloud SQL Auth Proxy secure connections? 27. How does IAM database authentication work in Cloud SQL? 28. How do you connect a Cloud Run service to Cloud SQL? 29. How do you connect GKE pods to Cloud SQL securely? 30. What is the difference between automated and on-demand backups in Cloud SQL? 31. What happens when you perform point-in-time recovery in Cloud SQL? 32. How do you restore a Cloud SQL backup to another instance? 33. How do cross-region read replicas help with disaster recovery in Cloud SQL? 34. How do you promote a read replica in Cloud SQL? 35. How can you reduce replication lag in Cloud SQL? 36. How do you troubleshoot high CPU usage on a Cloud SQL instance? 37. How do you troubleshoot 'too many connections' errors in Cloud SQL? 38. How does storage auto-increase work in Cloud SQL? 39. When should you choose Cloud SQL Enterprise Plus over Enterprise? 40. How does Data Cache improve performance in Cloud SQL Enterprise Plus? 41. How can you minimize downtime during Cloud SQL maintenance? 42. How do you encrypt Cloud SQL data with customer-managed encryption keys? 43. How do you audit database access in Cloud SQL? 44. What is the difference between Cloud SQL and AlloyDB? 45. When would you choose Spanner over Cloud SQL? 46. How do you migrate an on-premises MySQL database to Cloud SQL? 47. How can you optimize Cloud SQL costs? 48. How do you scale a Cloud SQL instance? 49. What are the limitations of Cloud SQL compared with an on-premises database? 50. How do you monitor Cloud SQL with Cloud Monitoring?

1. What is Google Cloud SQL?

Cloud SQL is Google Cloud's fully managed relational database service for MySQL, PostgreSQL and SQL Server. You work with a normal database engine, but Google runs the servers, storage and most of the operational chores underneath it.

Google takes care of provisioning, OS and engine patching, automated backups, replication and failover. You still own the schema, indexes, query tuning, database users and network access rules.

It fits OLTP applications, web backends and lift-and-shift migrations where you want standard engine compatibility without babysitting VMs. When a single primary instance is no longer enough, AlloyDB or Spanner are the usual next steps.

Take quiz
Who applies operating system patches to a Cloud SQL instance?
You, by logging in over SSH
Google Cloud, as part of the managed service
A cron job you schedule on the instance
Your Compute Engine instance group
Which of these is NOT a Cloud SQL engine?
MySQL
PostgreSQL
SQL Server
Oracle Database

2. What are the database engines supported by Cloud SQL?

Cloud SQL supports three engines, each with several major versions. Check the current version list before you plan an upgrade, because older versions are retired over time.

Engine Worth knowing
MySQL InnoDB storage engine, replication based on GTIDs, familiar tools like mysqldump
PostgreSQL Popular extensions such as PostGIS, pgvector and pgaudit; the cloudsqlsuperuser role instead of a true superuser
SQL Server Editions such as Express, Web, Standard and Enterprise; Windows authentication through Managed Microsoft AD

Features differ a little per engine. For example, some flags, extensions and replication options exist for one engine only, so read the engine-specific docs rather than assuming parity.

Take quiz
Which Cloud SQL engine can use Managed Microsoft AD for Windows authentication?
SQL Server
MySQL
PostgreSQL
All three engines identically
Which PostgreSQL extension would you enable for geospatial queries?
pgvector
pgaudit
PostGIS
pg_stat_statements

3. What are the editions available in Cloud SQL?

Cloud SQL comes in two editions: Enterprise and Enterprise Plus. Enterprise is the general-purpose default. Enterprise Plus targets workloads that need stricter availability and more performance headroom.

Feature Enterprise Enterprise Plus
Availability SLA 99.95% (excludes maintenance) 99.99% (includes maintenance)
Planned maintenance downtime Short outage Near zero (under a second)
Transaction log retention for PITR Up to 7 days Up to 35 days
Data Cache (local SSD) Not available Available
Machine families Shared-core, standard, high-memory, custom Performance-optimized

You pick the edition when you create the instance, and you can upgrade later. Plus costs more per vCPU, so use it where the SLA or latency actually matters.

Take quiz
Which edition provides a data cache backed by local SSD?
Enterprise only
Both editions equally
Neither; it is a separate add-on service
Enterprise Plus
What is the longest transaction log retention for PITR in Enterprise Plus?
7 days
35 days
14 days
90 days

4. What is a Cloud SQL instance connection name?

The instance connection name is the unique identifier of a Cloud SQL instance, written as PROJECT_ID:REGION:INSTANCE_NAME. For example, shop-prod:us-central1:orders-db.

The Auth Proxy, language connectors and Cloud Run all use it to find the right instance. On Cloud Run the same string becomes the Unix socket path under /cloudsql/.

You can read it from the console or with this command:

gcloud sql instances describe orders-db --format="value(connectionName)"

Mixing up the order of project, region and name is a common cause of 'instance not found' errors.

Take quiz
Which value is a valid instance connection name?
shop-prod/us-central1/orders-db
orders-db.us-central1.shop-prod
shop-prod:us-central1:orders-db
us-central1:shop-prod:orders-db
A Cloud Run service reaches Cloud SQL through a Unix socket located at:
/cloudsql/INSTANCE_CONNECTION_NAME
/var/run/mysqld/mysqld.sock
/tmp/cloudsql.sock
/mnt/disks/cloudsql

5. What are the machine types available in Cloud SQL?

Machine types decide how many vCPUs and how much memory your instance gets. For MySQL and PostgreSQL on the Enterprise edition you generally choose from these families:

  • Shared-core (db-f1-micro, db-g1-small): cheap, for dev and test. Not covered by the SLA.
  • Standard (for example db-n1-standard-4): balanced vCPU to memory ratio.
  • High-memory (for example db-n1-highmem-8): more memory per vCPU for caching-heavy workloads.
  • Custom (db-custom-CPUs-MEMORY_MB): you pick the exact vCPU and memory within allowed ratios.

Enterprise Plus uses its own performance-optimized types. Changing the machine type restarts the instance, so plan it for a quiet period.

Take quiz
Which machine types are not covered by the Cloud SQL SLA?
High-memory types
Shared-core types such as db-f1-micro
Custom types
All types on regional instances
What does the tier db-custom-4-16384 describe?
4 GB of memory and 16 vCPUs
4 replicas with 16 GB of disk
A 4-node shard with 16 TB of storage
4 vCPUs and 16384 MB of memory

6. What is the purpose of automated backups in Cloud SQL?

Automated backups give you a scheduled safety net. Cloud SQL takes one backup per day inside a four-hour backup window you choose, and you can restore the data after accidental deletes, bad deployments or corruption.

By default the last 7 automated backups are kept, and you can raise that up to 365. Older ones are removed automatically.

Backups are also the base for point-in-time recovery, since PITR replays transaction logs on top of a backup. High availability on MySQL and PostgreSQL depends on them being enabled too.

Automated backups are deleted with the instance, so keep a final backup or an export in Cloud Storage if the data must outlive it.

Take quiz
How many automated backups does Cloud SQL retain by default?
7
1
14
30
Besides restores, which feature depends on automated backups being enabled?
Query Insights
Authorized networks
Point-in-time recovery
Shared-core machine types

7. What is a read replica in Cloud SQL?

A read replica is a copy of the primary instance that receives changes asynchronously and serves read-only traffic. It lets you move reporting queries and read-heavy endpoints off the primary.

Replicas can live in the same region, in another region, or even outside Google Cloud as an external replica. You create one with:

gcloud sql instances create orders-db-r1 \
  --master-instance-name=orders-db \
  --region=us-east1

Because replication is asynchronous, a replica can lag behind. Do not send reads there if the user must see their own write instantly.

Take quiz
How are changes propagated from the primary to a Cloud SQL read replica?
Synchronously on every commit
By nightly full dumps
Through manual SQL exports
Asynchronously
Which operation is NOT possible on a standard read replica?
Running SELECT queries
Running application writes against it
Placing it in a different region
Monitoring its replica lag

8. How do you enable high availability for a Cloud SQL instance?

High availability is turned on by choosing the regional availability type. Cloud SQL then runs a standby in a second zone of the same region.

  1. Make sure automated backups are enabled, plus binary logging for MySQL or PITR for PostgreSQL.
  2. Set the availability type to REGIONAL at creation, or patch an existing instance.
  3. Confirm in the console that a standby zone is shown, and test it with a manual failover.
gcloud sql instances patch orders-db --availability-type=REGIONAL

Enabling it on a running instance can cause a brief interruption, so schedule it for a quiet period. Expect the instance cost to roughly double because a standby is provisioned.

Take quiz
Which setting enables high availability on a Cloud SQL instance?
--ha=true
--enable-multi-zone
--availability-type=REGIONAL
--standby-count=1
How does enabling HA affect the instance's cost?
It roughly doubles it, because a standby is provisioned
It is free of charge
It only adds network egress fees
It adds a small per-query fee

9. How do you create a Cloud SQL instance using gcloud?

Use gcloud sql instances create with the engine version, tier and region. A typical PostgreSQL example:

gcloud sql instances create orders-db \
  --database-version=POSTGRES_16 \
  --edition=ENTERPRISE \
  --tier=db-custom-2-7680 \
  --region=us-central1 \
  --storage-type=SSD \
  --storage-size=50GB \
  --storage-auto-increase \
  --backup-start-time=02:00

Here db-custom-2-7680 means 2 vCPUs and 7680 MB of memory. Add --availability-type=REGIONAL for HA, and set the postgres password afterwards with gcloud sql users set-password.

Creation takes a few minutes, and the Cloud SQL Admin API must be enabled in the project first.

Take quiz
In the tier db-custom-2-7680, what does 7680 stand for?
Disk size in GB
Memory in MB
Maximum connections
IOPS limit
Which flag lets the disk grow automatically as data increases?
--auto-resize-disk
--disk-autogrow
--expand-storage
--storage-auto-increase

10. What is the Cloud SQL Auth Proxy?

The Cloud SQL Auth Proxy is a small client-side program that opens a secure tunnel from your application to a Cloud SQL instance. Your app connects to 127.0.0.1 and the proxy handles the rest.

It authenticates with IAM credentials, encrypts traffic with TLS, and removes the need to allowlist client IP addresses or manage server certificates yourself.

./cloud-sql-proxy --port 5432 shop-prod:us-central1:orders-db
psql "host=127.0.0.1 port=5432 user=app dbname=orders"

The caller needs the Cloud SQL Client role, and the Cloud SQL Admin API must be enabled.

Take quiz
Which IAM role lets a principal connect through the Auth Proxy?
Cloud SQL Client
Cloud SQL Viewer
Compute Network User
Storage Object Viewer
Where does the application connect when using the proxy locally?
The instance's public IP directly
Port 443 of the Cloud SQL Admin API
A local port on 127.0.0.1
An internal load balancer in the VPC

11. What are the ways to connect to a Cloud SQL instance?

There is no single 'right' way. The choice depends on where the client runs and how strict your network policy is.

Method Needs Good for
Auth Proxy IAM role, Admin API VMs, GKE, local development
Language connectors (Java, Python, Go, Node.js) IAM role, library in the app Apps that want no sidecar
Public IP + authorized networks Allowlisted CIDR, SSL recommended Quick access from fixed IPs
Private IP VPC with private services access Workloads inside the VPC
Private Service Connect Endpoint in the consumer VPC Cross-VPC or cross-project access
gcloud sql connect Cloud Shell or gcloud Ad hoc admin sessions

In production, most teams combine private connectivity with the proxy or a connector for IAM-based authorization.

Take quiz
Which connection method requires adding the client's IP range to authorized networks?
Cloud SQL Auth Proxy
Language connector
Private IP from inside the VPC
Direct connection to the public IP
Which options give a TLS-encrypted, IAM-authorized connection without hand-managed certificates?
Public IP with SSL disabled
The Auth Proxy or a language connector
A firewall rule on port 3306 only
Shared VPC with no encryption

12. What is a maintenance window in Cloud SQL?

A maintenance window is the one-hour slot, chosen by day of week and hour (UTC), in which Cloud SQL prefers to apply updates such as OS patches and engine minor versions.

If you do not set one, maintenance can start at any time. Setting it makes downtime predictable. During maintenance a non-Plus instance restarts, which interrupts connections for a short time.

gcloud sql instances patch orders-db \
  --maintenance-window-day=SUN \
  --maintenance-window-hour=3

You can also pick whether the instance receives updates earlier or later in the rollout, which is handy for putting staging ahead of production.

Take quiz
How long is a Cloud SQL maintenance window?
Four hours
A full day
One hour, set by day and hour
30 seconds
What happens if no maintenance window is configured?
Maintenance can begin at any time
Maintenance never runs
Maintenance runs only on weekends
The instance is stopped for maintenance

13. What are database flags in Cloud SQL?

Database flags are the Cloud SQL way of setting engine parameters, such as max_connections or slow_query_log. They replace editing my.cnf or postgresql.conf, since you have no file system access.

gcloud sql instances patch orders-db \
  --database-flags=max_connections=500,log_min_duration_statement=500

Only supported flags are accepted, and values are validated. Some flags apply immediately while others need a restart, so check the flag's page before changing it in production.

Note that --database-flags replaces the whole set. Include every flag you want to keep.

Take quiz
How do you change max_connections on a Cloud SQL instance?
Edit postgresql.conf over SSH
Set it as a database flag on the instance
Run ALTER SYSTEM as the superuser
Upload a custom config file to Cloud Storage
Why might applying a flag cause downtime?
Flags always rebuild the disk
Flags recreate the instance in another zone
Flags apply only during maintenance
Some flags take effect only after a restart

14. How do you import and export data in Cloud SQL?

Both operations go through Cloud Storage. You export a SQL dump or CSV into a bucket, or import one from a bucket. The instance's service account needs access to that bucket.

# export
gcloud sql export sql orders-db gs://shop-backups/orders.sql.gz --database=orders --offload

# import
gcloud sql import sql orders-db gs://shop-backups/orders.sql.gz --database=orders

The --offload flag runs the export on a temporary serverless instance so the primary is not slowed down. For CSV use export csv with a --query.

For very large or continuous moves, Database Migration Service is a better fit than dumps.

Take quiz
What does the --offload option do for exports?
Runs the export on a temporary serverless instance to protect the primary
Exports only rows changed today
Writes the dump to a read replica's disk
Splits the file into one per table
What does the instance's service account need for an import?
Owner on the VPC
Compute Instance Admin
Permission to read objects in the bucket
Cloud SQL Admin on the bucket

15. What is Query Insights in Cloud SQL?

Query Insights is the built-in tool for finding slow or heavy queries without installing anything. It shows database load broken down by query, user, database and client address, so you can see which statement is responsible for a CPU spike.

You can drill into a normalized query to view its latency over time and, on PostgreSQL, sample query plans. Adding sqlcommenter tags in your app code links a query back to the application route or controller that issued it.

Enable it from the console or with a flag, and review it first when users report slowness.

Take quiz
What does Query Insights chiefly help you identify?
Which IAM roles are unused
Which firewall rules block traffic
Which backups failed last night
Which queries are generating the most database load
What does adding sqlcommenter tags to queries allow?
Encrypting the query text
Tracing a query back to the application code that sent it
Caching results in Memorystore
Routing queries to replicas automatically

16. Define point-in-time recovery in Cloud SQL?

Point-in-time recovery (PITR) lets you rebuild an instance's data as it was at a specific second, such as one minute before a bad DELETE ran.

It works by combining a backup with continuous transaction logs: binary logs on MySQL and write-ahead logs on PostgreSQL. You must have automated backups and PITR (log retention) turned on beforehand, because you cannot recover to a time the logs do not cover.

gcloud sql instances clone orders-db orders-db-recovered \
  --point-in-time="2026-10-22T09:14:00Z"

The result is always a new instance. The original is not rolled back.

Take quiz
PITR in Cloud SQL produces:
An in-place rollback of the original
A read replica of the original
A new instance containing data as of the chosen time
A CSV export in Cloud Storage
PITR on PostgreSQL relies on which kind of log?
Write-ahead logs
Slow query log
General query log
Audit log

17. How do you stop and start a Cloud SQL instance?

Stopping is done by setting the activation policy to NEVER, and starting by setting it to ALWAYS.

gcloud sql instances patch dev-db --activation-policy=NEVER   # stop
gcloud sql instances patch dev-db --activation-policy=ALWAYS  # start

While stopped, you do not pay for vCPU and memory, but storage and any reserved static IP are still billed. Data is preserved. Existing connections drop immediately.

This is a common cost saver for development databases, often automated with Cloud Scheduler. Do not use it for production, since a stopped instance serves nothing.

Take quiz
Which setting stops a Cloud SQL instance?
--state=STOPPED
--activation-policy=NEVER
--availability-type=ZONAL
--pause=true
Which resource is still billed while an instance is stopped?
vCPU
Memory
All compute and storage are free while stopped
Storage

18. What is Database Migration Service in Google Cloud?

Database Migration Service (DMS) is Google's managed tool for moving databases into Cloud SQL (and AlloyDB) with little downtime. It supports MySQL, PostgreSQL and SQL Server sources, from on-premises, other clouds or Compute Engine.

A migration job first copies a full snapshot, then keeps applying ongoing changes (change data capture) until you are ready to cut over. At that point you stop writes on the source, let the destination catch up, and promote it.

You still need to check source prerequisites, such as binary logging enabled for MySQL and network connectivity between source and destination.

Take quiz
What technique lets DMS keep the destination current after the initial copy?
Continuous replication of ongoing changes
Hourly full re-imports
Manual CSV uploads
Nightly snapshots only
What is the final step of a DMS continuous migration?
Delete the source immediately
Export a SQL dump
Promote the destination after cutover
Resize the destination to shared-core

19. What is the difference between Cloud SQL and a self-managed database on Compute Engine?

Both run the same engines. The difference is who carries the operational work and how much low-level control you keep.

Area Cloud SQL Self-managed on Compute Engine
Patching and upgrades Google applies them in your window You schedule and run them
Backups, PITR, HA Built-in features You design and script them
OS and file access None Full root access
Superuser and extensions Restricted (no SUPER, limited extensions) Anything the engine allows
Tuning freedom Supported flags only Any parameter or filesystem layout
Operational effort Low High

Pick self-managed only when you need an unsupported extension, custom plugin or OS-level tuning. Otherwise Cloud SQL saves a lot of toil.

Take quiz
Which capability is unavailable on Cloud SQL but available on a self-managed VM?
Automated backups
Read replicas
Maintenance windows
SSH access to the database host
Who handles minor engine patching in Cloud SQL?
You, with apt-get
Google, within your maintenance window
The VPC administrator
Nobody; patching is not supported

20. What is the difference between high availability and read replicas in Cloud SQL?

They solve different problems. HA protects you from a zone failure. Read replicas help you scale reads and prepare for regional disasters.

Aspect High availability Read replica
Goal Keep the primary available Offload reads, support DR
Data copy Synchronous, via regional disk Asynchronous replication
Serves queries No, standby is idle Yes, read-only
Failover Automatic Manual promotion
Location Another zone, same region Same region, other region or external
Possible data loss on failure None for committed transactions Anything not yet replicated

Production systems usually combine them: HA on the primary and one or more replicas for reads and DR.

Take quiz
Which feature can serve read-only application queries?
The HA standby instance
Automated backups
A read replica
The maintenance window
Which one promotes automatically when the primary's zone fails?
The HA standby
A cross-region replica
An external replica
An on-demand backup

21. How does Cloud SQL high availability work?

A regional instance has a primary in one zone and a standby in another zone of the same region. Both attach to a regional persistent disk, which synchronously replicates every write across the two zones. A committed transaction is therefore on both zones' storage before it is acknowledged.

Cloud SQL watches the primary through health checks. If it stops responding, or its zone fails, the standby starts the engine on the same data and takes over. Clients keep using the same IP address.

flowchart LR
  A[App] --> B["Primary in zone A"]
  B --> C["Regional persistent disk"]
  C --> D["Replicated copy in zone B"]
  E["Standby in zone B"] -.-> D
  B -. health check fails .-> E
  E --> A

The standby does not serve reads. For read scaling you still need read replicas.

Take quiz
How does a regional Cloud SQL instance keep its data safe across zones?
Nightly dumps copied to the other zone
A regional persistent disk replicates writes synchronously
Asynchronous binlog shipping to a replica
A cron job running rsync
What does the HA standby instance do during normal operation?
Serves read-only queries
Runs scheduled backups only
Handles all write traffic
Stays idle and ready to take over

22. What happens to applications during a Cloud SQL failover?

Existing connections are dropped, and any transaction that had not committed is rolled back. Committed transactions are safe because of the synchronous regional disk.

The standby then becomes the primary and the instance becomes reachable again, usually within a minute or two. It keeps the same IP address and connection name, so you do not change configuration.

Your application must handle the interruption:

  1. Catch connection errors and retry with exponential backoff.
  2. Make writes idempotent so a retry does not duplicate data.
  3. Use a connection pool that discards broken connections.

You can rehearse with gcloud sql instances failover orders-db. Once the old zone recovers, the instance can move back, and a manual failback is possible.

Take quiz
What happens to uncommitted transactions during failover?
They are rolled back and must be retried
They are replayed automatically
They are committed on the standby
They are saved to a backup
Which command tests failover behavior?
gcloud sql instances restart-zone
gcloud sql backups failover
gcloud sql instances failover
gcloud sql replicas switch

23. Why use private IP for Cloud SQL instances?

Private IP keeps database traffic on Google's internal network. The instance gets an internal address from your VPC's reserved range, so it is never exposed to the public internet.

  • Security: no public attack surface and no authorized-network lists to maintain.
  • Latency: traffic stays inside Google's network and avoids internet hops.
  • Compliance: many policies require databases to have no public address.

It is set up through private services access, which allocates an IP range and creates a VPC peering with Google's service producer network. Two things to remember: private IP cannot be removed from an instance once enabled, and you can still disable the public IP separately.

Take quiz
What is a key security benefit of Cloud SQL private IP?
Queries are cached automatically
Passwords are no longer needed
Backups become free
The instance is not reachable from the public internet
Which statement about enabling private IP is true?
It can be toggled off any time
It cannot be removed from the instance later
It requires a public IP to remain on
It works without any VPC

24. How does private services access work with Cloud SQL?

Private services access (PSA) connects your VPC to the VPC that Google manages for Cloud SQL. You reserve an IP range, then create a peering with servicenetworking.googleapis.com. Cloud SQL carves instance addresses out of that range.

flowchart LR
  A["Your VPC"] -- reserved range --> B["VPC peering"]
  B --> C["Google managed service VPC"]
  C --> D["Cloud SQL instance private IP"]
gcloud compute addresses create google-managed-services \
  --global --purpose=VPC_PEERING --prefix-length=16 --network=prod-vpc

gcloud services vpc-peerings connect \
  --service=servicenetworking.googleapis.com \
  --ranges=google-managed-services --network=prod-vpc

Peering is not transitive. On-premises networks reaching Cloud SQL through a VPN need custom route advertisement, otherwise only the peered VPC can connect.

Take quiz
What does private services access create between your VPC and Cloud SQL?
A Cloud NAT gateway
A public load balancer
A VPC peering to a Google-managed network
A dedicated Interconnect
Why do on-premises clients often fail to reach a PSA instance over VPN at first?
VPC peering is not transitive, so custom routes must be advertised
Cloud SQL blocks all VPN traffic
The instance supports only public IP
VPN requires SQL Server

25. How is private services access different from Private Service Connect?

Both give private connectivity, but through different mechanisms.

Aspect Private services access Private Service Connect
Mechanism VPC peering with a reserved IP range Endpoint (forwarding rule) pointing to a service attachment
IP allocation Range reserved in your VPC Single internal IP per endpoint
Cross-VPC or cross-project Harder, peering limits apply Natural fit, list allowed consumer projects
Transitivity issues Yes, peering is not transitive No peering involved
Address overlap Must avoid overlaps Overlap is less of a problem

Choose PSC when many VPCs or projects need access, or when peering limits and IP planning are painful. PSA remains simple for a single VPC.

Take quiz
Which option avoids VPC peering altogether?
Private services access
Private Service Connect
Authorized networks
Shared-core machine types
How does a consumer reach a Cloud SQL instance with PSC?
By peering the VPCs
By enabling a public IP only
By using the HA standby
Through an endpoint with an internal IP in its own VPC

26. How does the Cloud SQL Auth Proxy secure connections?

The proxy secures a connection in three steps, none of which you manage by hand.

  1. It reads IAM credentials (a service account or user) and asks the Cloud SQL Admin API for a short-lived client certificate, valid for about an hour.
  2. It opens a TLS connection to the instance's proxy port (3307 on the server side) and verifies the server identity against the instance's CA.
  3. It refreshes the certificate before it expires, so long-running apps stay connected.

Because authorization is based on IAM, you do not need authorized networks or hand-installed SSL certificates. The client IP can change freely.

The tunnel only protects the transport. You still log in with a database user, unless you also enable IAM database authentication.

Take quiz
What credential does the proxy request from the Cloud SQL Admin API?
A short-lived client certificate
A permanent SSH key
A static database password
A VPN profile
Does the Auth Proxy replace database user login by itself?
Yes, database users are no longer needed
Yes, but only on MySQL
No, it secures transport and authorization to the instance only
No, because it only works over public networks

27. How does IAM database authentication work in Cloud SQL?

With IAM database authentication, a Google identity logs in to the database using a short-lived OAuth 2.0 access token as the password instead of a stored secret.

  1. Turn on the flag: cloudsql.iam_authentication=on for PostgreSQL or cloudsql_iam_authentication=on for MySQL.
  2. Add the IAM user or service account as a database user of type IAM.
  3. Grant the identity Cloud SQL Instance User (to log in) and Cloud SQL Client (to connect).
  4. Connect with the Auth Proxy using --auto-iam-authn, or a language connector with IAM auth enabled.

Tokens last about an hour, which is why the proxy or connector refreshes them for you. Then access is revoked centrally through IAM, and there are no passwords to rotate in app config.

Take quiz
What serves as the password in IAM database authentication?
A static key stored in Secret Manager
The instance's root password
The service account's email address
A short-lived OAuth 2.0 access token
Which role allows an identity to log in as an IAM database user?
Cloud SQL Viewer
Cloud SQL Instance User
Logs Writer
Compute Admin

28. How do you connect a Cloud Run service to Cloud SQL?

The simplest path uses the built-in Cloud SQL connection on Cloud Run, which mounts a Unix socket into the container.

gcloud run deploy orders-api \
  --image=us-docker.pkg.dev/shop-prod/app/orders:latest \
  --add-cloudsql-instances=shop-prod:us-central1:orders-db \
  --service-account=orders-sa@shop-prod.iam.gserviceaccount.com

The service account needs Cloud SQL Client. In your code, connect to the socket path /cloudsql/shop-prod:us-central1:orders-db (for PostgreSQL, use it as the host).

Alternatively, use private IP with Direct VPC egress or a serverless VPC connector, or the language connector inside the app. Keep each instance's connection pool small, since many Cloud Run instances multiply the total connection count.

Take quiz
Which deploy flag attaches a Cloud SQL instance to a Cloud Run service?
--attach-database
--cloudsql-proxy=true
--add-cloudsql-instances
--sql-socket
Why should each Cloud Run instance keep a small connection pool?
Many instances multiply the total connections hitting the database
Cloud Run limits pools to one connection
Small pools raise IAM quotas
Unix sockets are slower with pools

29. How do you connect GKE pods to Cloud SQL securely?

The standard pattern is to run the Auth Proxy as a sidecar container in the same pod and authenticate it with Workload Identity, so no key files are stored in the cluster.

  1. Create a Google service account with the Cloud SQL Client role.
  2. Bind it to the Kubernetes service account used by the pod via Workload Identity.
  3. Add the proxy as a sidecar and point the app at localhost.
containers:
  - name: app
    image: orders-api:1.4
    env:
      - name: DB_HOST
        value: "127.0.0.1"
  - name: cloud-sql-proxy
    image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:VERSION
    args:
      - "--private-ip"
      - "--port=5432"
      - "shop-prod:us-central1:orders-db"
    securityContext:
      runAsNonRoot: true

Pin a current 2.x version of the image. For Kubernetes Jobs, use the proxy's --quitquitquit endpoint, otherwise the sidecar keeps the Job from finishing.

Take quiz
Which GKE feature removes the need for service account key files in the proxy sidecar?
Node auto-provisioning
Workload Identity
Pod Security Admission
Cluster Autoscaler
What problem does the proxy's --quitquitquit option solve for Kubernetes Jobs?
It forces TLS 1.0 fallback
It rotates database passwords
It reduces the instance's connection limit
It lets the sidecar be shut down so the Job can complete

30. What is the difference between automated and on-demand backups in Cloud SQL?

Aspect Automated backup On-demand backup
Trigger Scheduled daily in your backup window You start it whenever you want
Window Four-hour window you choose Any time
Retention Count of 1 to 365, oldest removed automatically Kept until you delete it
Typical use Daily protection and base for PITR Before a risky schema change or release
Survives instance deletion Not guaranteed Not guaranteed

A good habit is to take an on-demand backup just before a migration or deployment, so you have a precise rollback point. For anything that must outlive the instance, export to Cloud Storage or take a final backup before deleting it.

gcloud sql backups create --instance=orders-db --description="before v2.3 schema change"

Take quiz
Which backup type is kept until you remove it manually?
On-demand backup
Automated backup
Transaction log segment
HA standby snapshot
When is an on-demand backup most useful?
Only during the maintenance window
Instead of PITR logging
Right before a risky schema change
After deleting the instance

31. What happens when you perform point-in-time recovery in Cloud SQL?

Cloud SQL does not rewind your running instance. It builds a new instance containing data as of the timestamp you pick.

flowchart TD
  A["Choose recovery timestamp"] --> B["Pick latest backup before that time"]
  B --> C["Create new instance from backup"]
  C --> D["Replay binary logs or WAL up to the timestamp"]
  D --> E["New instance ready"]
  E --> F["Cut over app or copy back lost rows"]

The timestamp must fall inside the log retention period (up to 7 days on Enterprise and up to 35 on Enterprise Plus) and cannot be in the future. The new instance gets its own IP and name, and read replicas are not carried over.

A practical tip: if only a few rows were lost, recover to a new instance and copy those rows back, rather than switching the whole application.

Take quiz
What does PITR create in Cloud SQL?
A rolled-back version of the same instance
A read replica of the primary
A manual SQL dump only
A new instance with data as of the chosen time
Which step follows creating the instance from a backup?
Running VACUUM FULL
Replaying logs up to the target timestamp
Promoting a replica
Rotating the instance password

32. How do you restore a Cloud SQL backup to another instance?

List the backups, then restore one into a target instance. The target's current data is overwritten, so be sure you picked the right one.

gcloud sql backups list --instance=orders-db

gcloud sql backups restore 1698000000000 \
  --backup-instance=orders-db \
  --restore-instance=orders-db-staging

  • The target must use the same engine, and a compatible database version.
  • Its storage must be at least as large as the source's.
  • The target is unavailable while the restore runs.
  • Restoring across projects is possible with the right permissions.

For a safer approach, restore into a freshly created instance so production data is never at risk. Refreshing a staging database this way is a common use.

Take quiz
What happens to the target instance's existing data during a restore?
It is merged with the backup
It is archived to Cloud Storage
It is overwritten by the backup
It is kept and the backup is skipped
Which requirement applies to the restore target?
Its storage must be at least as large as the source
It must be in a different region
It must have HA enabled
It must use SQL Server

33. How do cross-region read replicas help with disaster recovery in Cloud SQL?

A cross-region replica keeps an asynchronously updated copy of your data in a different region. If the primary's region goes down, you promote that replica to a standalone primary and point the application at it.

Two points matter in an interview. First, replication is asynchronous, so your recovery point objective is not zero. A few seconds of recent writes may be missing. Second, promotion is a manual, one-way step unless you use the advanced DR features of Enterprise Plus, which add planned switchover and replica failover with the original replica relationship restored afterwards.

  1. Detect the regional outage and stop traffic to the old primary.
  2. Promote the cross-region replica.
  3. Update application endpoints or DNS.
  4. Enable backups and HA on the new primary, then create new replicas.

Cross-region traffic also adds some egress cost and latency, so size the replica for the full production load, not only reads.

Take quiz
What limits the recovery point objective of a cross-region replica?
Replicas cannot be promoted
Asynchronous replication can leave a small amount of data unreplicated
Backups are disabled on replicas
Cross-region replicas read from tape
What is the first action after deciding to fail over to a cross-region replica?
Delete the primary's backups
Resize the replica to shared-core
Disable private IP
Promote the replica

34. How do you promote a read replica in Cloud SQL?

Promotion detaches the replica from its primary and turns it into a standalone, writable instance. It is irreversible: the instance never becomes a replica of the old primary again.

gcloud sql instances promote-replica orders-db-r1

  1. Stop or pause writes on the primary, if it is still running.
  2. Wait for replica lag to reach zero to avoid losing data.
  3. Run the promote command.
  4. Update your application to use the promoted instance.
  5. Turn on automated backups and HA, and create new replicas.

Typical reasons are disaster recovery, a region migration, or creating an independent copy for testing.

Take quiz
What is true about promoting a Cloud SQL replica?
It is irreversible and makes the replica standalone
It can be undone with one command
It keeps the replica read-only
It deletes the original primary
What should you check before a planned promotion to minimize data loss?
That the maintenance window is set
That Query Insights is on
That replica lag has dropped to zero
That the machine type is shared-core

35. How can you reduce replication lag in Cloud SQL?

Start by watching the metric database/replication/replica_lag, then look for the cause. Typical fixes:

  • Size the replica properly. It should be at least as powerful as the primary. An undersized replica cannot apply changes fast enough.
  • Break up huge writes. One massive update or delete creates a big transaction the replica applies serially. Do it in batches.
  • Add primary keys. On MySQL, row-based replication of tables without a primary key is very slow.
  • Enable parallel replication. On MySQL, increase parallel replica workers using the relevant flags.
  • Watch long replica queries. On PostgreSQL, queries conflicting with replay can stall it. Review max_standby_streaming_delay and hot_standby_feedback, and weigh their trade-offs.
  • Check the network. Cross-region replicas depend on inter-region latency and bandwidth.

Alert on lag so you notice before users read stale data.

Take quiz
Which MySQL table design issue commonly slows replication?
Using too many indexes
Using utf8mb4 columns
Partitioned views
Missing primary keys
Why should big batch updates be split into smaller batches?
Batches bypass binary logging
A single huge transaction is applied serially and increases replica lag
Smaller batches avoid IAM checks
Replicas reject transactions over 1 MB

36. How do you troubleshoot high CPU usage on a Cloud SQL instance?

Work from the symptom to the query, not the other way round.

  1. Confirm the spike in Cloud Monitoring (database/cpu/utilization) and note when it began. Correlate with a deployment or traffic change.
  2. Open Query Insights and sort by load to find the heaviest queries.
  3. Inspect live activity to catch runaway sessions.
  4. Use EXPLAIN on the suspects. Look for sequential scans, missing indexes and bad joins.
  5. Check connection counts. A connection storm or a retry loop burns CPU.
  6. Fix the query or index first. Scale up only if the workload is legitimately larger, and push reads to a replica.
-- PostgreSQL
SELECT pid, state, now() - query_start AS runtime, query
FROM pg_stat_activity WHERE state <> 'idle' ORDER BY runtime DESC;

-- MySQL
SHOW FULL PROCESSLIST;

Throwing a bigger machine at an unindexed query only delays the problem.

Take quiz
Which tool is the best first stop to find the queries causing load?
Cloud NAT logs
IAM Recommender
Query Insights
VPC Flow Logs
What is usually the best fix for a CPU spike caused by a sequential scan?
Add or correct an index and rewrite the query
Disable automated backups
Switch to HDD storage
Enable more authorized networks

37. How do you troubleshoot 'too many connections' errors in Cloud SQL?

The error means the instance reached its max_connections limit, which depends on the instance's memory. First find out who is holding connections.

-- PostgreSQL
SELECT state, count(*) FROM pg_stat_activity GROUP BY state;

-- MySQL
SHOW STATUS LIKE 'Threads_connected';

  • Many idle connections point to missing pooling or leaked connections in the application.
  • Cloud Run or GKE autoscaling can multiply pools. Pool size times instance count must stay under the limit.
  • A pooler such as PgBouncer or ProxySQL lets thousands of clients share a few database connections.
  • Raising max_connections helps only if memory allows, since each PostgreSQL connection costs memory.
  • Scaling up the instance raises the default limit.

Long-term, fix the application's pooling and cap concurrency rather than only raising the limit.

Take quiz
What typically determines the default max_connections on Cloud SQL?
The number of read replicas
The instance's memory
The storage type
The maintenance window
Which tool lets many client connections share fewer database connections?
Cloud Armor
Cloud CDN
A larger boot disk
A connection pooler such as PgBouncer or ProxySQL

38. How does storage auto-increase work in Cloud SQL?

When it is enabled, Cloud SQL watches free disk space and, once it falls below an internal threshold, adds storage automatically without downtime. The threshold scales with the current disk size.

There are some important points:

  • The increase is permanent. Cloud SQL cannot shrink a disk afterwards, and you pay for the larger size.
  • You can set a ceiling with --storage-auto-increase-limit to stop runaway growth.
  • If the limit is reached or auto-increase is off, a full disk makes writes fail.
  • Alert on database/disk/utilization at about 80%.
gcloud sql instances patch orders-db --storage-auto-increase --storage-auto-increase-limit=500

If you need to reduce disk size, the only route is migrating the data to a new, smaller instance with export and import or DMS.

Take quiz
What cannot be done to a Cloud SQL disk after it has grown?
Shrink it
Grow it further
Back it up
Replicate it
What is the purpose of --storage-auto-increase-limit?
To set the backup window
To restrict query length
To cap how large automatic growth can make the disk
To limit IAM users

39. When should you choose Cloud SQL Enterprise Plus over Enterprise?

Choose Enterprise Plus when downtime and latency have a clear business cost. The upgrade makes sense in these situations:

  • You need a 99.99% SLA that includes maintenance, rather than 99.95% excluding it.
  • Planned maintenance must be near-zero downtime, under a second for the switch.
  • The workload is read-heavy and its working set exceeds memory, so the Data Cache pays off.
  • You need longer PITR, up to 35 days of log retention.
  • You want advanced disaster recovery, such as planned switchover between regions.
  • You need higher-performance machine types for steady heavy load.

For internal tools, dev environments and moderate workloads, Enterprise is usually enough and cheaper. Compare the monthly cost difference against the cost of an hour of downtime.

Take quiz
Which requirement most clearly points to Enterprise Plus?
A development sandbox
A single-user prototype
A database used once per month
A 99.99% SLA that includes maintenance
How long can PITR log retention be on Enterprise Plus?
Up to 24 hours
Up to 35 days
Up to 3 days
Unlimited

40. How does Data Cache improve performance in Cloud SQL Enterprise Plus?

Data Cache adds a layer of local SSD between memory and the persistent disk. Hot data pages that no longer fit in RAM are kept on the local SSD, so reads avoid the slower network-attached disk.

It helps most for read-heavy workloads whose working set is bigger than memory but smaller than the whole database. You choose the cache size, and it is part of the instance, so it works on the primary and on replicas where configured.

  • Lower read latency for hot data.
  • Fewer reads hitting the persistent disk, so more stable performance.
  • No application change is needed.

It does not help write-heavy workloads or a working set that already fits in memory, so measure the cache hit ratio and read latency before paying for it.

Take quiz
Where does Data Cache keep hot pages that do not fit in memory?
On a Cloud Storage bucket
In Memorystore
On local SSD
In the HA standby's RAM
Which workload benefits most from Data Cache?
Read-heavy workloads with a working set larger than memory
Write-only logging tables
Tiny datasets that fit entirely in RAM
Idle development databases

41. How can you minimize downtime during Cloud SQL maintenance?

You cannot eliminate maintenance, but you can control when it hits and how much it hurts.

  • Set a maintenance window in your quietest hour so updates do not surprise you.
  • Use a deny maintenance period, up to 90 days, to block updates around events like a sale or year-end close.
  • Choose the rollout timing so staging receives updates before production.
  • Watch the maintenance notifications and use self-service reschedule when a window is inconvenient.
  • Use Enterprise Plus, where planned maintenance means near-zero downtime.
  • Make clients resilient with retries and connection pool validation.

Deny periods only delay updates, so you cannot skip them forever. Test the application behavior against a restart in staging.

Take quiz
What is the maximum length of a deny maintenance period?
7 days
90 days
30 days
1 year
What gives planned maintenance near-zero downtime?
A shared-core machine type
A larger disk
Disabling backups
The Enterprise Plus edition

42. How do you encrypt Cloud SQL data with customer-managed encryption keys?

By default Google encrypts all Cloud SQL data with Google-managed keys. With CMEK, you control the key in Cloud KMS.

  1. Create a key ring and key in Cloud KMS, in the same region as the instance.
  2. Create the Cloud SQL service identity for the project.
  3. Grant that service identity the Cloud KMS CryptoKey Encrypter/Decrypter role on the key.
  4. Create the instance with the key.
gcloud beta services identity create --service=sqladmin.googleapis.com

gcloud sql instances create orders-db \
  --database-version=POSTGRES_16 --region=us-central1 --tier=db-custom-2-7680 \
  --disk-encryption-key=projects/shop-prod/locations/us-central1/keyRings/sql/cryptoKeys/orders

CMEK must be chosen when the instance is created, so existing instances cannot be switched over. You would migrate data into a new one. Replicas need a key in their own region. Disabling or destroying the key makes the data unreadable, so protect it.

Take quiz
When must CMEK be configured for a Cloud SQL instance?
At instance creation
Any time, with a live toggle
Only after the first backup
Only during maintenance
What happens if the Cloud KMS key is disabled or destroyed?
Google switches to a default key silently
Only backups are affected
The instance data becomes inaccessible
Nothing, because data is cached

43. How do you audit database access in Cloud SQL?

Auditing has two layers, and interviewers like to hear both.

Layer What it records How
Cloud Audit Logs Admin API actions such as creating, deleting or patching instances Admin Activity logs are always on; enable Data Access logs as needed
Database-level audit Who ran which statements pgAudit on PostgreSQL, the audit plugin on MySQL, SQL Server Audit

For PostgreSQL, enable the flag cloudsql.enable_pgaudit=on, set pgaudit.log (for example ddl,write), then create the extension:

CREATE EXTENSION pgaudit;

Entries go to Cloud Logging, where you can route them to BigQuery or a SIEM. Using IAM database authentication makes the audit trail attributable to real identities rather than a shared app user.

Take quiz
Which audit layer records the SQL statements users run?
Admin Activity audit logs
VPC Flow Logs
Billing export
Database-level auditing such as pgAudit
Where do Cloud SQL audit log entries end up?
Memorystore
Cloud Logging
Cloud Storage Nearline automatically
The instance's local disk only

44. What is the difference between Cloud SQL and AlloyDB?

AlloyDB is a PostgreSQL-compatible service built for heavier workloads, whereas Cloud SQL is the simpler general-purpose choice.

Aspect Cloud SQL AlloyDB
Engines MySQL, PostgreSQL, SQL Server PostgreSQL-compatible only
Storage Persistent disk attached to the instance Separate, log-based distributed storage layer
Analytics Standard engine Built-in columnar engine for analytical queries
Read scaling Read replicas Read pool instances
Availability 99.95% or 99.99% depending on edition 99.99% including maintenance
Cost Lower, simpler Higher, for demanding workloads

Pick Cloud SQL for typical OLTP, or when you need MySQL or SQL Server. Pick AlloyDB when a PostgreSQL workload needs more throughput, mixed analytics, or faster scaling of reads.

Take quiz
Which service supports SQL Server?
AlloyDB
Both identically
Cloud SQL
Neither
What does AlloyDB include to speed up analytical queries?
A columnar engine
A Memcached sidecar
A MapReduce cluster
A Bigtable index

45. When would you choose Spanner over Cloud SQL?

Choose Spanner when the database must scale horizontally or span regions. Cloud SQL is built around a single primary that scales vertically.

Aspect Cloud SQL Spanner
Scaling writes Bigger machine, then sharding in the app Add nodes, data splits automatically
Geography Regional primary, replicas elsewhere Multi-region with active writes
Consistency Strong on the primary, replicas lag Strong, externally consistent globally
Availability Up to 99.99% Up to 99.999% in multi-region setups
Compatibility Native MySQL, PostgreSQL, SQL Server GoogleSQL or a PostgreSQL dialect, less drop-in
Effort and cost Lower Higher, needs schema and app changes

If a single well-sized primary and a few replicas do the job, stay on Cloud SQL. Move to Spanner for global users, extreme write volume or five-nines requirements.

Take quiz
Which need most strongly suggests Spanner?
A small internal admin app
Globally distributed writes with strong consistency
A single-region dev database
A MySQL lift-and-shift with no growth
How does Cloud SQL scale write capacity?
By adding nodes automatically
By enabling a columnar engine
By turning on Data Cache only
Vertically, by moving to a bigger machine

46. How do you migrate an on-premises MySQL database to Cloud SQL?

For anything larger than a small database, use Database Migration Service with continuous replication, so downtime is limited to the cutover.

flowchart LR
  A["Assess source"] --> B["Create Cloud SQL destination"]
  B --> C["Create connection profile"]
  C --> D["Create and test migration job"]
  D --> E["Full copy then change replication"]
  E --> F["Stop writes and let lag reach zero"]
  F --> G["Promote and switch app"]
  1. Assess: check versions, storage engines and unsupported features.
  2. Prepare the source: enable binary logging in row format, create a replication user, and open connectivity (VPN, IP allowlist or reverse tunnel).
  3. Create the destination and the migration job, and run the test.
  4. Start the job, then monitor lag.
  5. Cut over: stop writes, wait for zero lag, promote, repoint the application.
  6. Validate row counts and application behavior before decommissioning the source.

For a small database where downtime is acceptable, a plain mysqldump and import is simpler.

Take quiz
What source setting does DMS need for MySQL continuous migration?
Binary logging enabled
Query cache enabled
MyISAM only tables
A public read replica
When should you promote the destination in a DMS migration?
Before the initial copy
Immediately after creating the job
After stopping writes and replication lag reaches zero
Only after deleting the source

47. How can you optimize Cloud SQL costs?

Most savings come from matching the instance to the real workload and cleaning up what is idle.

  • Right-size vCPU and memory using monitoring data and the recommender suggestions.
  • Stop non-production instances at night, for example with Cloud Scheduler. Storage is still billed.
  • Use shared-core machines for dev and test, but never production, since they have no SLA.
  • Buy committed use discounts for steady production instances.
  • Skip HA and Enterprise Plus where the SLA is not needed.
  • Delete unused replicas, old on-demand backups and abandoned clones.
  • Set a storage auto-increase limit and clean up big tables. Disks cannot shrink.
  • Keep replicas and clients in the same region to avoid egress charges.

Review the bill by SKU monthly. Storage and replicas often hide the surprises.

Take quiz
Which resource keeps costing money even when a Cloud SQL instance is stopped?
vCPU
Memory
Nothing at all
Storage
Which discount suits a steady production instance?
Preemptible pricing
Committed use discounts
Spot VMs
Free tier credits

48. How do you scale a Cloud SQL instance?

Cloud SQL scales mostly up, and it scales reads out. It does not scale writes horizontally.

  • Vertical: change the machine type with gcloud sql instances patch --tier. This restarts the instance, so do it in a quiet period.
  • Storage: disk can be increased without downtime (and automatically). It cannot be reduced.
  • Read scaling: add read replicas and route read-only queries to them in the application.
  • Caching and pooling: put Memorystore in front of hot reads and use a connection pooler.
  • Data design: add indexes, partition large tables, and archive old data.
gcloud sql instances patch orders-db --tier=db-custom-8-32768

When a single primary no longer keeps up with writes, the options are application-level sharding or moving to AlloyDB or Spanner.

Take quiz
What happens when you change a Cloud SQL machine type?
Nothing, it is instant and silent
The data is rebuilt from backup
The instance restarts
A new region is chosen
What is the standard way to scale read traffic?
Add read replicas and route reads to them
Add more authorized networks
Enable the maintenance window
Switch to shared-core

49. What are the limitations of Cloud SQL compared with an on-premises database?

Cloud SQL trades control for convenience. The main restrictions to remember:

  • No OS or shell access. You cannot SSH in or touch the file system.
  • No true superuser. MySQL has no SUPER privilege, and PostgreSQL uses the cloudsqlsuperuser role.
  • Limited extensions and plugins. Only supported ones can be installed, and custom ones cannot.
  • Supported flags only. Some engine parameters cannot be changed.
  • Single primary. There is no multi-primary writing, and HA is within one region.
  • Size limits. Storage and connection counts have caps that depend on the machine.
  • Some changes restart the instance, for example machine type changes and certain flags.

If a requirement collides with these, self-managed on Compute Engine, AlloyDB or Spanner may fit better. Check restrictions early, before committing a migration plan.

Take quiz
Which MySQL privilege is not available to Cloud SQL users?
SELECT
SUPER
INSERT
CREATE
Can you SSH into a Cloud SQL instance?
Yes, through Cloud Shell only
Yes, with an IAM role
Yes, on HA instances only
No, there is no OS-level access

50. How do you monitor Cloud SQL with Cloud Monitoring?

Cloud SQL publishes metrics under cloudsql.googleapis.com automatically. Build a dashboard and alert policies around the metrics that predict trouble first.

Metric Why it matters
database/cpu/utilization Sustained high values mean missing indexes or undersizing
database/memory/utilization Shows pressure on cache and connections
database/disk/utilization Alert near 80% to avoid a full disk
database/network/connections Spots connection leaks before max_connections
database/replication/replica_lag Shows stale replicas
database/up Quick availability signal

Combine metrics with Cloud Logging for error logs and slow query logs (enabled by flags such as log_min_duration_statement), and Query Insights for query-level detail. Route alerts to email, Slack or PagerDuty with notification channels.

Take quiz
Which metric would you alert on to avoid a full disk?
database/disk/utilization
database/up
database/replication/replica_lag
database/cpu/utilization
Where do slow query logs from Cloud SQL appear once enabled by flags?
The instance's /var/log folder via SSH
Cloud Billing reports
Cloud Logging
Cloud Build history
«
»

Comments & Discussions