This page provides language-specific links to informaton about how to set up a connection from an App Engine application and a Cloud SQL 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 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 Second Generation
Connecting to Second Generation instances from App Engine standard environment is not supported.