0

I'm trying to setup a web app in Google App Engine standard environment using Flask and MySQL.

I know Google App Engine is capable of scaling it's instance dynamically based on the performance needed but I'm unsure how I can do this for my MySQL servers.

For the MySQL connection I try to connect to Google Cloud SQL. I know how this works for a single instance but I would like to know whether it's possible to connect multiple instances and thereby allow the possiblity to dynamically scale my storage while using the same data.

So far I've found information how to do this on Google Computing Engine instances and Google Cloud SQL via this link but couldn't find out how this would work on Google App Engine standard environment.

Lennard Deurman
  • 213
  • 1
  • 3
  • 11

2 Answers2

0

Each GAE service instance will connect to your Google Cloud SQL as a separate client, using the same credentials. There's nothing to worry about in this respect, except maybe the cost of scaling/sizing your Google Cloud SQL instances if you have many GAE instances or limiting the number of GAE instances to keep the performance decent. From Best practices (the whole page is probably a useful read):

  • 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 limiting the maximum number of App Engine instances. For more information, see Scaling elements.
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97
  • Thank you, I understand that Google App Engine can scale dynamically and let the created instances connect to one Google Cloud SQL Instance, but I'm looking for a solution for the limited space and performance on this Cloud SQL instance. Is there a way I can connect Google App Engine to multiple instances and so increase the database space on Google Cloud SQL? – Lennard Deurman Jun 27 '19 at 09:19
0

As @dan-cornilescu correctly mentioned, Google App Engine automatically scales horizontally and handles the connections to your Cloud SQL instance without you having to care about.

But taking a look at your last comment on his answer :

Thank you, I understand that Google App Engine can scale dynamically and let the created instances connect to one Google Cloud SQL Instance, but I'm looking for a solution for the limited space and performance on this Cloud SQL instance. Is there a way I can connect Google App Engine to multiple instances and so increase the database space on Google Cloud SQL?

I will go ahead and give you some options in order to address the limited space and performance of your Cloud SQL instance. Regarding the limited space, when creating your Cloud SQL instance you can check the option “Enable automatic storage increases” under the “Configure machine type and storage” dropdown.

Regarding having multiple instances, remember that Cloud SQL instances scale vertically but not horizontally, so the first option I would recommend you is to switch to Google Cloud Spanner if what you are seeking is horizontal scalability. At the moment is the only database within Google Cloud products that allows to do so and is the choice to go.

You can also “fake out” the horizontal scalability by creating multiple Cloud SQL instances, which is indeed a best practice. While doing so, you only have to take into consideration that the amount of instances allowed per project is 40 and you will have to request an increase if you wish to have more.

bhito
  • 2,083
  • 7
  • 13