My involvement with a Google App Engine-based project is winding down, so I’ll share what I’ve learned.
Building for App Engine is tough
If you’re thinking about starting a project on GAE, think about it carefully. I had a hard time with it for several reasons, but my first mistake was thinking, “Oh, this will be a way to get an app going quickly and cheaply without all that sysadmin trouble.” This is not the case for a few reason:
- mission-critical features depend on GAE-specific APIs which are often poorly documented and not very googlable.
- you’ll be learning a new database (NDB), a new memcache server and a new task queuer, among others.
- GAE support for Django is so-so. You’ll probably have to learn a new framework. Make sure to use WebApp2 if you’re trying to set up a lightweight application.
If you want quick, cheap prototyping, consider Heroku instead. You’ll have access to all the standard components of the modern web stack (rather than GAE-specific ones) and Heroku supports many languages.
Development server != Production server
The development environment differs from the production environment in several ways. The ones I found are:
- No memory limit on the development server
- No timeouts on the development server
- Asynchronous features don’t work on the development server (futures don’t resolve until they’re explicitly waited for)
So, something that works in development may not work in production! (And apparently the same is true for the test stubs.)
You might have to pay for your staging environment
Unless you look into AppScale (I didn’t), you’ll need another GAE instance for your staging server. Unless you pay, you won’t be able to test rigorous features of the app.
The Datastore has some drawbacks
You pay to use it. If your application will be database-intensive (reads, writes and/or deletes), it’s gonna cost you. It adds up – make sure to set a nice low cap on your budget.
The pricing is non-intuitive at first. You’re charged for each value in the stored entity, its key, and each value in any indexes that entity has.
Indexes are expensive to maintain (because of the point above). Remove ones you don’t desperately need!
It’s an unfamiliar, low-level API. To me, anyways – it’s no ActiveRecord.
Don’t cache if you’re running big queries
Make sure to pass the
use_cache=false context option or else it will kill your instance for memory overload! For example:
Use pages to run big queries
Datastore operations are limited to 60 seconds, even on the backend. If you’re iterating over lots of entities and/or performing time-consuming tasks on each one, you’ll want to use the
Query#fetch_page method. For example, creating a CSV based on a query:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Ok, that’s all for now!