May 13, 2010

Runtime optimisation on AppEngine for Java (GAE/J)

1. Install AppStats from http://code.google.com/appengine/docs/java/tools/appstats.html
Its basically a servlet provided by Google that intercepts GAE inner workings and logs it to your applications data store. It comes with a servlet that is able to display the data in nice ways. Leave all settings as described.

2. Log into the appstats servlet and keep the browser open

3. Open the Firebug network tab

4. Make a request to your appengine application

5.In the response headers: You see messages about the cost and CPU usage. The cost is for 1000 requests, the usage numbers are for this request. Sample:



Google explains:
If you access your site while signed in using an administrator account, App Engine includes per-request statistics in the response headers. The header X-AppEngine-Estimated-CPM-US-Dollars represents an estimate of what 1,000 requests similar to this request would cost in US dollars.

6. Go into the Appstats and click to see your last request. You get a timeline diagram and each point you called the data store. Click on these points to see the stack trace that called them.

7. Use Firebug to determine the page loading time from a users point of view.

Our appengine application remains for ca. 20 seconds active before the next request causes another cold start (clearly distinguishable by page loading times; time measures with stop watch by hand). A cold start every 20 seconds is in the worst case 4320 cold starts per day. Given a cold start cost of $ 0,00377529 for 12 seconds startup time, we end up with ca. $ 49 per month. All other request hit certainly a warm JVM and are hence much cheaper.

There is also a little Firefox plugin to display the costs in the Firefox error console.

No comments:

Post a Comment