Search code examples
google-cloud-platformgoogle-cloud-sql

What is faster way to connect to SQL database on Google Cloud


I understand there are two ways for dockerized application to cennect to Cloud SQL database:

  • setting db Private Ip
  • attaching cloud_sql sidecar to docker

Which one is faster?


Solution

  • There is a bit of confusion here - by cloud_sql sidecar, you are referring to using the Cloud SQL proxy in a sidecar pattern as described here.

    The proxy has two different connection methods - it uses either Public IP or Private IP when connecting to your Cloud SQL instance. You can specify which you want it to use with the --ip_address_types flag (example).

    When it comes to latency between Public and Private IPs, Private IP are typically faster. This is because private IPs stay local within Google's infrastructure.