This page provides language-specific links to information about how to set up a connection from an App Engine application to a PostgreSQL instance.
For information about the various options for connecting to Cloud SQL, see Connection Options for External Applications.
General information for connecting to Cloud SQL from App Engine
When connecting to Cloud SQL from App Engine standard or flex environment, you can connect only by using the instructions linked below. You cannot use IP addresses (public or private) to connect to Cloud SQL from App Engine applications. Connections from App Engine applications to Cloud SQL are secure and encrypted; you do not need to configure TLS/SSL.
When you are connecting to Cloud SQL from App Engine, keep these best practices in mind:
- App Engine has the ability to automatically create more instances
when load increases. If the number of App Engine instances increases
beyond what the Cloud SQL instance is sized to handle, your
Cloud SQL instance will not be able to meet the demand. You can avoid
this issue by setting the
max_instancesvalue for the
basic_scalingelement in your
app.yamlfile. For more information, see Scaling elements.
- Open database connections consume resources; your application should always close connections when they are no longer being used. For App Engine standard environment, there is a hard limit on the number of connections an App Engine instance can have open to Cloud SQL. If your application requires more open connections, consider using connection pooling.
App Engine standard environment to PostgreSQLFor information about connecting from App Engine standard environment to Second Generation instances, see the App Engine documentation for your programming language:
|Python 3||Using Cloud SQL for PostgreSQL with Python 3beta|
|Java||Using Cloud SQL for PostgreSQL with Java|
|Node.js||Using Cloud SQL for PostgreSQL with Node.js|