Using RDBMS on Google App Engine : Google Cloud SQL
We have been working on Google App Engine since its early days and have developed and ported several applications on the platform for our clients. One of the major hinderance for our Enterprise clients for not being able to move to GAE has been Datastore being the only storage option available till date. Major reasons for these enterprises not using Datastore are:
- (In case of migration) Substantial efforts in adapting the application code base to Google Datastore specifications
- Potentially huge data-migration efforts
- Vendor Lock-In as both the application code and data residing in Datastore can’t be taken to an in-premise Infrastructure or another cloud platform seamlessly
Keeping all these requests and potential business opportunities in mind, Google has recently announced Cloud SQL.
What is Google Cloud SQL
- It’s a Relational Database on Cloud offering from Google.
- Offers MySQL Database environment with JDBC support for Java applications and DB-API support for Python applications.
- Being a service on Cloud, it offers traditional advantages of any Cloud service like no maintenance, administration, replication and backup efforts
- To ensure high-availability, data gets replicated across multiple geographic regions
- Easy to use Web-Interface for managing multiple Instances
Google Cloud SQL & Google App Engine
A very good integration has been provided for your applications running on Google App Engine to use Google Cloud SQL as back-end storage mechanism. Furthermore, one SQL instance can be shared across multiple Google App Engine applications. This feature should be quite helpful as often we have a family of Web Applications for different user-requirements but still sharing the same Database.
Cloud SQL is still in limited preview mode so you need to request access for the same. More information is available here.
Once you have got access, you can visit Google APIs Console and should be able to see Google Cloud SQL tab on the left side menu. You can create a new Cloud SQL instance from there. During the creation, you can
- Specify the storage capacity (current options are 1GB, 5GB and 10 GB)
- Specify one/more App Engine Application ID’s allowed to access this DB instance. It should be noted that multiple applications can access one Cloud SQL instance or one application can access multiple SQL instances.
Once an instance is created, you can access it either through API Console’s Web Browser SQL prompt or through a command line tool from your computer. Detailed instructions for downloading and configuring command line tool are available here. To quickly get going, we will use Web Browser. Once inside SQL prompt, we can execute commands as if we are working on local MySQL Database installation. Do keep in mind that all identities in Google Cloud SQL are case-sensitive i.e. Entries and entries are considered different tables.
Integrating GAE Application with Cloud SQL
For Java developers, detailed instructions are available here. Similar instructions for Python can be accessed here. Following the steps, I was able to get an application on GAE accessing Cloud SQL Database in less than 15 minutes. During development stages, you can also test the application behavior accessing your local MySQL Database. Configuration steps for the same are provided here
Export/Import Cloud SQL provides the possibility of importing your existing MySQL data to Cloud SQL Database. This feature is very important when we are thinking of migrating our existing in-premise applications to Cloud. Similarly if for some reasons, we want to move our applications from GAE platform, an export utility is also provided. In both the cases, though we need to pass via Google Cloud Storage, yet another Service offering from Google to store your data on cloud. Detailed instructions about exporting and importing data are provided here
Usage Stats You can access usage statistics on variety of parameters and across multiple time-lines through your instance dashboard. As the service is currently in preview mode, it’s usage is free but once Google launches it officially it will most likely be a paid service. This would then be an important place for determining possible improvement areas in your application for cost and performance optimizations.
I think it is big positive addition for increasing the reach of GAE platform inside enterprises. I am yet to try it on a serious project but the integration looked quite straightforward. Possibility of accessing the same instance from multiple GAE applications also appears to be a good feature while designing or migrating multiple applications using same Database. One of things which I feel lacking is inability to access Cloud SQL instance from applications outside Google App Engine environment. This may be a bottleneck when we think about phased migration of an application family using the same Database instance or one of the applications can’t be deployed on GAE platform because of some reasons. Workarounds are possible but ideal solution would be to provide REST Service to access the instance from anywhere. Hope this is in future pipeline. Looking forward to hearing your comments and experiences on Cloud SQL and GAE.