Grails vs. Python on Google AppEngine


A few weeks ago I got fed up with the bad performance I was getting on Google AppEngine for my Grails project. I was also having trouble figuring out how to combine references for Entities to build more complex structures.

As a result I finally lost it and started experimenting with Python on Google AppEngine. So here are some of my conclusions.

Framework

I still wanted to have a framework to build on for developing my application. Since Grails has a lot of dependencies that are sent to GAE I wanted something that was already supported by GAE. Partially because I heard that sending all these dependencies around in Google’s datacenter was one of the reasons for the bad performance I was experiencing.

So I chose Django. The Django framework is already installed on the web servers hosting the applications on Google AppEngine, which would reduce the load cost for dependencies.

There is also a Django helper that will help you use GAE features through the normal Django API.

Static files

Something I was missing from the Grails solution was the use of static files, most of the client side java script I server were static, so I just wanted a high expiration date and static serving of the files. This is inherent in Python GAE app.yaml file.

To be honest I am quite impressed by what I can do with the app.yaml file. I can set expiration dates on content, declare parts of the urls I define as secure. I can even reserve some parts of my site for me personally. Allowing me to build Administration interfaces for the application.

I will however miss the UI-performance plugin, as it handles my java script files the way I want, potentially even better. Now I have to manually set up something that during deployment compress and bundle my java script files.

Working with the API

Working with the python API for GAE gave me a better sense of control over what I was doing. The concepts of the Datastore and other features made much more sense. All of a sudden making applications with more complex data structure wasn’t an issue. How things connect to each other was inherent and the documentation was there to assist me when I missed something.

I also had to write less code to achieve the same features, however part of this could be because I had already solved the problem once and could produce a better solution with this.

What I really liked was testing, where I earlier had had problems with getting tests to run for Grails with the AppEngine plugin. The tests not only worked out of the box, but they took roughly 0.1 second to run 10 tests.

Performance

So finally, the performance part. Remember this was one of the reasons I made the switch.

Before I get to the actual numbers, I have to mention that there are some changes that affect the results. When hosting on Python I could serve most of my pages as static HTML files, where using Grails I was depending on the virtual machine to boot up before content was delivered. Performance for the static files could probably be achieved if the Java app is configured to serve the files as static files through GAE.

And now the numbers

Avg. Response time
Grails 4985 ms
Python 252 ms
Uptime
Grails 53.48%
Python 100%

These numbers are captured using Pingdom, with checks running every 5 minutes on the website from all over the world.

Conclusion

Since I don’t require any plugins for Grails for this project and Python serving so well I’ll go with Python for this project.

This being said as I know Grails will get performance improvements for Google AppEngine in coming versions.

Bookmark and Share

, , ,

  1. #1 by Wilhelm Svenselius on April 7, 2010 - 11:35

    252ms response doesn’t exactly seem fast, if you’re serving static pages? What’s the overhead?

  2. #2 by Morten on April 7, 2010 - 11:39

    Well, you have to remember that the tests are run from all over the world and are on average runs. Also, their against a datacenter so it’s not very likely that the same webserver is serving the requests. Meaning they have to move data around. You are very welcome to dig further into it either on Google Appengine’s documentation or ask on the mailing lists.

    The fact that I get good responses locally and decent globaly is enough for me.

  3. #3 by Tomas on April 27, 2010 - 17:16

    would be interesting to see Gaelyk numbers in there too.

  4. #4 by Morten on April 27, 2010 - 20:47

    Yes, I agree. I’ll see if I can do some measurements on a gaelyk project to get a reference point.

  5. #5 by Mark on September 26, 2010 - 03:28

    Have you had a chance to look at Gaelyk yet? I am looking into this myself although getting Grails up and running is a challenge at least with 1.3.4 w/JDO.

  6. #6 by Morten on September 26, 2010 - 19:21

    I did look a litle bit on Gaelyk. From what I’ve seen it is the way you want to go if you want to use Groovy on AppEngine. It still suffers from the loading time for initial hits, but with Gaelyk its down to around 7 seconds instead of hitting the deadline (30 sec) and beyond that Grails currently do.

    Also, Gaelyk’s model is much closer to AppEngine which means it will be easier to comprehend the documentation, regarding more advanced DataStore Entities.

    I know of a few people whom have had some success in development on Gaelyk, but the initial loading hit still holds the development back. If you ask me :)

    This was however a few months ago so there could be improvements I havn’t seen/heard of. Let me know what you find out!

(will not be published)