Home > Cloud, Java, Web > Using RDBMS on Google App Engine : Google Cloud SQL

Using RDBMS on Google App Engine : Google Cloud SQL

December 16, 2011

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.

Getting Started

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.

About these ads
Categories: Cloud, Java, Web Tags: ,
  1. aglassman
    January 6, 2012 at 5:37 PM | #1

    How is the speed of Cloud SQL vs the datastore for large datastes? I’d assume it would be slower and harder to scale. A RDBMS would be nice for smaller apps so I might have to look into testing out the Cloud SQL service.

    • January 7, 2012 at 7:59 AM | #2

      I have not done any of these tests but based upon my earlier experiences, Google Datastore is designed for massive scalability. The point here is whether your application is suitable or requires those features. When we need lot of relational constraints and consistency is more important than speed, RDBMS makes more sense over NoSQL. What CloudSQL provides is a solution for these situations where we don’t have to worry about replication, data-sharding, fault-tolerance etc.

  2. January 6, 2012 at 11:20 PM | #3

    We tried CloudSQL using Hibernate 4 and we encountered the following error frequently -

    23:16:38,720 WARN SqlExceptionHelper:143 – SQL Error: 0, SQLState: null
    23:16:38,721 ERROR SqlExceptionHelper:144 – Could not fetch URL: https://www.googleapis.com/sql/v1/jdbc/exec?alt=proto

    With ends results and commit failure during save/update. I think this product is definitely not ready for production usage. The concept is cool though.

    • January 7, 2012 at 8:02 AM | #4

      Thanks for the update JT.

      The application being in preview and Invite-Only mode, we should not expect it to be Production Ready. The idea is to have users test, provide comments and feedback to make it more complete.

  3. fedrick
    April 29, 2012 at 1:07 PM | #5

    i already send request access to use this service two days ago, but still no response..
    usually, how long it takes to get the response, or is there any possibility that i can’t get the permission and no response at all?
    i hope that’s not gonna happen, cz i really need this service immediately for my final project..
    thank you for your answer..

    • April 30, 2012 at 4:28 PM | #6

      Hello Fedrick,

      Can’t really say about the process adopted by Google for approval/rejection of the requests. You may just have to follow up with them. Good luck for your project.

Comments are closed.

Get every new post delivered to your Inbox.

%d bloggers like this: