Google App Engine (for Java) Rundown
July 5, 2009
I’ve recently got myself a Java app engine account from google but have held out about reviewing the various features until I had tested it in anger. Well, now I have!
Background Details
I have two applications running on app engine, one is a jsp based website www.oxfordgeekjam.net, which is no more than a static site with a bit of generated markup and one Java servlet application which makes use of several other google APIs. All my development work is done using the opensolaris operating system from Sun (now part of oracle).
What You Get
When you register for a google app engine account (python or java) you get space to host ten applications. Once they are gone you’re on your own! Each one of your apps has a quota which is reset every 24 hours, this quota includes factors such as CPU load, bandwidth etc. Once you breach these, you are on your own again unless you have signed up for googles pay as you go type service, which automatically charges for anything above the standard quotas.
When you register one of your ten applications, you must give it a unique name which becomes it’s application ID. To access your app you can use the URI [applicationID].appspot.com and also your own domain as well if you choose (see below). Its worth noting that once an app has been registered it can not be deleted to make room for another app!
Your application also comes with a “dashboard” which is kind of like a control panel for your app. It gives you information about how much of your quota you are using as well as providing an interface to your server logs. This second point is crucial because one thing you don’t get with the app engine is direct access to the file system space of your application (see deployment below).
Using Your Own Domain Name
The first site is hosted using its own domain name (rather than the default *.appspot.com). To use my own registered domain name, which I bought through a third party vendor rather than google, was a bit fiddly to begin with but now I know the process should be a cinch. To use your own domain you must have the ability to change your own DNS settings, in particular the CNAME records. Most domain vendors will allow you to do this as did eurodns with whom mine was registered with. You also have to register with google apps (yes, another google service to register with) to prove domain ownership and link your domain to your google “web master tools”. After that you simply need to click on versions in you app dashboard and link the domain to your app.
One downside of the process, and one that is causing quite a stir with other app engine developers, is that you cannot have a naked domain resolve to your application. That is to say, if I registered thebestdomainever.com the URI as it stands can NOT resolve to your app! www.thebestdomainever.com or anything.thebestdomainever.com would be fine though! Of course the way to get around this is to redirect the naked domain to the google acceptable domain, but I understand some registrars don’t allow this, again I was lucky, mine did!
Coding the Application
For vanilla jsp applications this is no more difficult than coding the pages and bundling them with the xml deployment descriptor and a couple of settings files in standard WAR format. The process is somewhat more difficult when it comes to writing servlets and using regular java classes.
There is a plugin for the eclipse IDE which is supposed to mange the coding and build process for you but I haven’t used it therefore cannot comment! I used netbeans (as I always do) and managed to configure the IDE relatively easily with a bit of help from the documentation, and using apache ant to manage the build. I won’t go into too many details unless somebody asks for it but it basically involves downloading the app engine SDK in zip format (which rolls in at a hefty 20Mb) and importing the com.google.appengine libraries. App engine applications use the Java Servlet Standard so most developers should feel right at home.
The only thing to watch out while coding is that all applications run in a sand box with a restricted white-list of java classes which are allowed to be used, so you may want to check the dependencies of your favorite libraries before using them!
Deploying the Application
This is the part of the process which I found really pleasantly surprising. The testing and deployment process worked (for me) straight out of the box!
Given the following constraints I really appreciate this level of detail…
- I’m using opensolaris
- I was using a really early version of the app engine API
- The SDK is a single download regardless of whether you use a mac, linux or windoze
To run the app using the localhost as a testing server was as simple as issuing the command…
dev_appserver.sh [war-location]
to the shell.
Uploading the app to your app engine space is similarly easy…
appcfg.sh update [war-location]
One thing to note is that you must make sure that the settings file appengine-web.xml is in the WEB-INF folder and points to your application ID.
Once your app has uploaded, it has gone. You have no way of retrieving it back as there is no access to your application’s file space. This even includes access by the app itself (for obvious reasons). If you do need persistence and serialisation then you are encouraged to use google’s datastore, but this comes with quota limits.
Quotas
Each application has quotas which are reset every 24 hours. These quotas include CPU time, bandwidth (both ways), Mail and deployments, among others. If you go for google’s premium service then once you reach these quota limits then anything above the quota is charged for, if you don’t then app will not function for the part which requires the quota. There are also hard limits which even premium customers can’t breach. The ten application limit per app engine account is one.
Two of the quota limits are for google datastore api usage and URLFetch usage. So even if your app is only making use of google provided services then you are still limited to amount of traffic you are allowed.
Conclusions
Things I like
- The testing and uploading process is a doddle to use
- Once you’ve set up your IDE coding and deploying is also easy
- The service is free which makes the quotas quite generous
- Using you own domain is relatively easy and can be done any time before or after the app is finished
Things I Dislike
- Why oh why can’t I delete an application once I am done with it?
- Why can I only have ten applications, especially considering the above?
- Why am I penalised by quota limits for google’s own services? Shouldn’t they encourage use of their own services rather than those of third parties?
I hope this post is of some value to some of you, please feel free to comment and if you would like me to send you my netbeans and/or jsp development templates, I am more than happy to do so!
Cheers,
Matty
Resources
http://code.google.com/appengine/ – The Google App Engine
http://www.google.com/apps/intl/en/business/index.html – Google apps for business
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/WCC3.html – The WAR packaging standard
http://ant.apache.org/ – Apache ANT
http://java.sun.com/products/servlet/ – The Java servlet standard
http://code.google.com/appengine/docs/java/jrewhitelist.html – The Java class app-engine white-list
