App Engine Optimization

Google-IO-10

App Engine is a great tool to deploy any kind of web application without thinking about the physical structure to implement. Indeed, the PaaS Google Cloud provides a highly scalable infrastructure. This scalability can be set automatically, all managed by Google. But, it can also be scaled by ourselves at our convenience.

The objective of this article is to tune the application in order to reduce resources consumption, increase performances & therefore reduce costs.

The first thing to do is to setup an event recorder that can record all datastore access, memcache and URL fetch calls to the application. It is a great help to analyze application’s usage. The appstat tool has been specifically written for this task.

1. Memcache

GAE’s datastore is one factor that can be hungry on resources. With the appstats tool, you have to find which queries cost and do not need to be refreshed frequently. They will be put in the memcache.

2. Queries on datastore

Generally, queries are almost more reactive in the local server than in the production server. Plus, once the production infrastructure is shared, the delay response response of the queries can vary a lot. A fact is that direct lookups such as GET return four to five time faster than the QUERY ones. Although Objectify framework cache automatically every GET results but no QUERY. So entities must be retrieved by key/id using GETs.

3. Client side API calls

An App Engine application can have to make a lot of urlfetch calls on his server side. This can increase the number of the request to the application but also consuming the (incoming/outgoing) bandwidth for the application. So at the design step, it is a good practice to implement all GET HTTP call from the client side (using jquery, angularjs for example).

These were some tips on GAE optimization,  but the key to success is to perform an adapted & dedicated analyze to your resources needs.

We observed that improvements are applicable on different layers. Other tips can therefore be the subject of a future article.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s