There has a been a lot of badmouthing about Google's AppEngine new pricing. Basically it went from being rather cheap to just incredibly expensive compared to normal hosting. Each of my instances (using ~30 mb of memory) will now cost (0.08 x 24 hours x 30 days) ~= 57.6 $ per month. They generously offer you half price until november on Python instances... so it'll be only 28 $ per month per instance for a pair of months.
If your site has a reasonable amount of traffic you'll have several instances. In two weeks the cost of my private iPhone stats website will be going from 12$ a month to about 211$. Yes, Google is generous, they're leaving me a whole two weeks to adapt. I am even allowed to work on the week-end or at night if I want. If feel humbled by such generosity and to be honest it helps me fill my agenda that was otherwise empty.
But the cheap 211 $ price is only because Python instances are half-priced until november (to compensate they say for the lack of support for concurrency in Python until 2.7 is released.) After that, unless I spend an undetermined amount of hours on my stats website to implement concurrency possibly reducing the cost, the monthly cost will double. That is $ 422.– per month instead of $ 12.–. All that to save my iPhone apps stats using a total RAM for all instances that is below 256mb.
A bargain compared to say an OVH server that would only get me 16 GB of ram for 69 € / month . There's no way such a miserable machine could handle 700k requests writing to memcache per day... Oh wait it would. I wouldn't even even need memcache. I could just fucking write to the mysql database for every request and it'd work. Then I could use the rest of the machine's power to crack the human genome, again.
Of course my first reaction was anger but after calming down I found a simple trick :-)
A simple solution through simplificative optimization
Thankfully not all is lost. Using to some good old optimization and by trashing parts that weren't really necessary, I have been able to greatly reduce the cost of my stats websiste. Previously my /log page saved data in memcache and used an insane amount of memory of up to 30 Mb per instance. That was due to the titanesque processing required to store values in memcache and saving them to disk once every 20 minutes.
My previous code was basically an adaptation of this code.
I made some adaptations for the new pricing model and now the code is much simpler than before and reaches a very low latency so it can all run on one free instance instead of 7 :
Oh, and fuck you Google, seriously.
PS: While the code above is amusing it seems you can reduce further the load by just serving a static file instead, which I did.