Google App Engine

Google App Engine

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…

  1. I’m using opensolaris
  2. I was using a really early version of the app engine API
  3. 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

Oxford Geek Jam

June 2, 2009

Oxford Geek Jam logo

So the first Oxford Geek Jam is fast approaching with just five days to go until the event! Had loads of great feedback from folks especially following my rather poor pitch at Oxford Geek Night 12!

In many ways my low standard of my pitch served me well because it meant that people made the effort to come and speak to me in person to get more details about the event and take away a moo mini card!

So far people have kept their coding ideas and potential projects close to their chest although I have heard a few ideas that people will be bringing along! Plus I have one or two of my own.

Not sure how many people are coming yet, we have twelve confirmed, but we really need to keep this first Geek Jam as informal as possible to minimise the impact to our hosts the Jam Factory. Maybe if it’s a roaring success we can go more organised with the next one and provide a private venue/catering etc..

I’m hoping to see a good mix of people and skills for this event and I will reiterate, truly everybody is welcome.

All that remains now is to say, see you on the day!

Oxford Geek Jam, 10:30am, Sunday 7th June, Jam Factory, Oxford

Without the wind, the grass does not move. Without software, hardware is useless – Geoffrey James, The Tao of Programming

Old meets New!

May 20, 2009

Ok, I just finished an unusual project for a client today. Specs were roughly as follows…

  1. collect data daily from an embedded computer
  2. legacy interface of computer is DDE via a propriatory gateway app running on a windoze box
  3. Take said data and visualise it on the company intranet in the form of a graph

This really is old meets new here as I have no choice but to use the legacy DDE link but then it needs visualising on the net! There are several ways to do this and I know I will get shouted at by someone, but this is the way I opted for given the time constraints!

The Daemon Process

I created a daemon process in c++ which parses an XML configuration file containing the the DDE topic and the various data to be collected (re-usable of course by changing only the XML). Once a day the data is collected via DDE via the gateway app and is dropped into a SQL database instance. The daemon process lives and breathes on the same windoze box as the gateway app.

The Webserver

This is the easy bit! A quick Java class to run in Tomcat 6 to pick up the data from the database and visualise it in a graph applet! Incidentally, if you need a simple, does-what-it-says-on-the-tin, open source Java graph library, then look no further than the JavaTao, Java Charts library!
Dont you just love hacking together systems to include legacy gear? It’s not forward thinking, but it does make you think, dde has after all been with us since windows 2.0 way back in 1987!

All in all I spent about 10 hours designing, coding and testing this solution, that doesn’t include my midnight chinese takeaway though!

Cheers,

Matt

Resources

Java Charts JavaTao Charts Library

OGJ Logo
Getting excited now! We’re less than a month away from the very first Oxford Geek Jam!

So what is Oxford Geek Jam? It’s an event where like minded professionals (and interested parties) get together socially and put their collaborative thinking caps on to design write or discuss new coding ideas/projects. We came up with the idea after BarcampApacheOxford as the few remaining stragglers sat, chatted and listened to the incredibly talented offbeat song smith Ben Walker!

We have a great pool of talent attending and the event is generating a lot of interest. Coming along are Oleg Lavrovsky from Cisco, Ben Werdmuller of Elgg and Curverider fame as well as Matt Westcott the unofficial king of Javascript, amongst many notable others!

We have a date (7 June) and a place (Oxford Jam Factory) all that remains now is for me to pitch the event at Oxford Geek Night 12, armed with my moo.com mini cards promoting the event! Then just sit back and see who arrives on the day!

Looking forward to seeing you there!

Matt

Resources :

Oxford Geek Jam

BarcampApacheOxford

Ben Walker Ben Walker / I hate mornings

Oxford Jam Factory

Oxford Geek Night 12

moo.com online printing company

[REPOST FROM DECEMBER 2008]

Having recently changed my changed my operating system to Opensolaris I had to re-compile the unp library from (sadly the late) Richard Stevens definitive text Unix Network Programming.
Following the instructions provided with the library source, resulted in various compilation errors rendering the library impossible to compile. I have seen many posts on this subject but no definitive how-to to fix the problem. As Stevens himself points out…

“[He does] *NOT* have time to help everyone port the code to different environments”.

I can however help when it comes to Opensolaris build 2008.11!

To compile the library take the following steps (the steps in bold are the extra bits you need for Opensolaris)…

  1. Get the file unpv12e.tar.gz (which is the source distribution of the library)
  2. gunzip -c unpv12e.tar.gz | tar xvf – # Unpack the archive into a location of your choice
  3. cd unpv12e
  4. Open the file ‘configure’ in the text editor of your choice and change line 4374 to be the same as line 4372 (overwrite the existing line)
  5. ./configure # which should sort out the implementation differences
  6. cd lib # build the basic library that all programs need
  7. Open the file ‘unp.h’ in the text editor of your choice and comment out lines 114 to 117
  8. make
  9. cd ../libfree # continue building the basic library
  10. make
  11. cd ../libgai # the getaddrinfo() and getnameinfo() functions
  12. make
  13. cd ../libxti # opensolaris supports XTI
  14. make # opensolaris supports XTI

You should now be good to go! Just to make sure, try to build and run the intro project from the book…

cd ../intro # build and test a basic client program
make daytimetcpcli
./daytimetcpcli 127.0.0.1 # run the program

I must say that this book is the definitive text on the subject and I can’t recommend it heartily enough.

Happy hacking,

Matt

Resources…
Read more about the author Richard Stevens.
unpv12e.tar.gz – The original file from the book
unpprecomp.tar.gz – My precompiled library based on the instructions above for Opensolaris build 2008.11 for those who cant be arsed to do it themselves!

Hello Everybody!

May 9, 2009

Hello everyone!

I’ve abandoned my old blog because it became stagnent, mostly due to my idleness! This new blog here at word press is my attempt to start afresh!

Having in said that, some of my instructional posts from my original blog will be ported over here for new readers, so there may be a flurry of activity to begin with!

I always welcome comments and suggestions.

Cheers,

Matt