Use GAE Appstats to Discover Unnecessary RPC Calls

If you play seriously with Google’s App Engine, I guess you regularly scan an average CPU time per URL and other stats in your GAE Dashboard. I tend to do this especially after adding a new feature. Yesterday I added the first cron job to my new app and today was surprised with an average latency - it was around 130ms. Hmmm… I really didn’t expect that. I’ve already had Appstats installed so I decided to take a quick look.

I opened the Appstats, clicked on the last cron URL invocation and there is was:

All these RPC calls definitelly appeared wrong in the context of my simple cron job. Fortunately, The Appengine shows you not only the content of each RPC but the full stack trace of the invocation. This is very helpful so I quickly discovered that my HTTP request interceptor was initializing a user session, which I really don’t need for a cron job. After a quick fix was in place, the request timeline looked much better:

That’s much better - an average call is now around 25ms which is only 20% of the original implementation.

Now, this was just a cron job and the main gain (beside my satisfaction) is saving money on GAE. (Although my time on writing this post probably costs more than this change would save during the lifetime of the application. :-) ) The point, however, is that Appstats gives you a great insight on what’s going on in your application and where the latency is coming from. Even if you don’t care about costs, you should care about your users - they will appreciate snappier application.

Comments