Patterns of Doom
This demo shows how certain sub-optimal programming strategies that slow down app engine applications would look like in app stats. Click on any of the links below to produce the particular phenomenon.
For more details on this site or to suggest new patterns to add, check out my blog.
Chain of gets
This code should probably be called "death by a thousand cuts". It will perform a series of gets from the store, for example in a loop. Since each of these gets is an individual RPC, it will take additional time to perform. The pattern in app stats looks like a progression of small time slices; each of them very small, but the sum of them enormous. The better solution: fetch all those models in a single get, as shown here.
Staircase of gets
This pattern is inspired by a post by Nick Johnson, where you can find much more details than in this little post. The staircase of gets usually looks like a long
rpc plateau, followed by a subsequent chain of little get requests. The reason behind is often running a loop on the
results of a datastore query, and then doing something that causes additional data to be loaded (e.g. additional models
via reference properties). The solution is very similar as in Chain of Gets: find a way to collect all the references needed
in advance and fetch them in one big datastore get. The code on this page uses the prefetch_refprops method
suggested by Nick.
Chain of fetches
Very similar to chain of gets, but for web requests. After an initial query, the server has to do multiple urlfetches to get to data it needs (common in mashups). Since it performs one request after another, the operation takes time. The solution is to use asynchronous requests and fetch the data in parallel.