As anyone who knows me will already have noticed, I’m a quite an outspoken proponent of Google AppEngine. Many of my projects nowadays run on GAE, including this very blog, as I love the ease of deployment, the provided services and low cost. I decided to migrate this blog to it from a VPS after many troubles with Drupal (lack of customizability, security problems, etc). It didn’t help that it gets 60,000 uniques a day, mainly from my Python tutorial, and Drupal on my budget VPS was crumbling under the load. The fact that GAE includes a free tier which the traffic would never reach certainly didn’t hurt.
A few days ago, though, at Google I/O, pricing changes to GAE were announced that are quite stringent. This coincides with GAE leaving the preview stage, and thus having to be transformed into a finan cially viable platform for Google.
Pricing changesAmong the most surprising, contentious and unsettling changes (perhaps the most unsettling) was the migration from CPU-based billing to instance-based billing. In the old model, you would get 6.5 CPU hours per day and pay a fee ($0.10 per hour) for any additional CPU time that the application needs. In the new model, this is scrapped, and now you pay per instance-hour (a GAE instance is an instance of your code that is running and can serve requests). Many developers were dismayed by this, because they had optimized their applications to take up almost no CPU time, and now that wouldn’t matter.
This blog, for example, goes over one instance to two or three per day, depending on how many people are visiting it at the same time, and the free tier only includes 24 instance-hours a day. This means that if, in total, two more instances were spun up for five minutes a day, the entire site would be unavailable for the final ten minutes of the day. This, as you can surmise, is not very desirable.
To delve into the math of serving requests, if each page takes 50 msec to be generated, an instance can only serve 1000 / 50 = 20 pages per second. Even if most of those 50 msec are spent fetching pages from the datastore, your application still has to wait for the request to be served before it can serve new ones. GAE runs some calculations and, if it thinks a new visitor will wait more than a second to get a new page, it spins up a new instance, taking it down if it’s not needed for more than 15 seconds.
If your application is optimized to use close to no CPU time per request, you can have many instances spun up and still not rack up enough CPU time to exceed the free tier. App developers who had optimized their applications for CPU time were paying nothing, whereas now they will have to pay up to thousands of dollars per month to run the same applications they used to run for free.
The devil is in the detailsDevelopers would be right to be apprehensive, if it weren’t for one small detail. Google has introduced multithreading in Java and will begin introducing in Python instances with the release of Python 2.7. What this means is that, whereas with single-threading your application would have to twiddle its thumbs waiting for the API calls to the datastore to return, now it can serve other requests.
This means that, if your instance spends next to no CPU servicing a request, it could serve ten times more requests than it is now. This is, therefore, equivalent to having ten single-threaded instances running at a time.
As should be obvious by now, this change will dramatically reduce the instances required to serve your application’s pages, which makes this change much less of the big deal it was thought to be initially. Since this point is often overlooked, I felt I should clarify it here.
Closing wordsI, along with everyone else, was saddened and somewhat enraged by the pricing changes which Google announced, apparently after locking everyone in with a free tier, but things aren’t as bad as they appear. App Engine is maturing into a solid, comprehensive solution for deploying and automatically scaling applications, not least with the “graduation” of the High Replication Datastore to the role of the default datastore, the introduction of backends, and many other exciting changes.
We will still have to wait and see exactly how the pricing changes will impact people, but, by Google’s calculations, most applications that consume resources less than the free tier will not go over it after the pricing changes. Some uses, such as sending email, have seen severe limi ts, but that doesn’t impact nearly as many users as the new instance prices.
My initial thoughts were that I would move everything off GAE as soon as I had the chance, but, after understanding the details a bit better, I am relieved and confident that we will be getting a much more reliable and stable platform for our applications, which will also hopefully be priced competitively compared to the other platforms (AWS, Rackspace, etc). After all, the free tier is meant to be there to help you in the initial stages of your application, when it isn’t getting enough traffic to warrant paying for servers, and to easily and smoothly let your cos ts scale up to whatever your application demands.