OK, my take on cloud computing for the independent developer.
I refer the interested reader to a recent GigaOm article on cloud computing’s three separate models [infrastructure, platform, software as a service]. I’m solely interested in the platform as a service model; third party platforms to which I can deploy webapps and have them scale [relatively] painlessly to a large audience at an affordable cost; the sort of thing that’s really only been available to the small guy with Apache/PHP until recently [if you're ever tried to deploy a Rails app prior to the launch of Heroku or Passenger, you'll know what I mean].
There’s a slight apples-to-oranges thing going on here. AppEngine is fairly and squarely a platform-as-a-service model, 100% owned, developed, hosted by Google. Heroku is a small startup which uses Amazon EC2 infrastructure-as-a-service model to host their Rails deployment platform; one layer of cloud computing supported by another. For my purposes, they are direct competitors.
I should also say this isn’t an exhaustive survey, just my personal preferences and experience. I’m sure other folk in this space [Appjet, Stax] have interesting things to say - I just haven’t got around to looking at them yet.
Language
Simple shootout - Python [AppEngine] vs Ruby [Heroku]. I started with Python in 2003 - what a breath of fresh air after years of Java. Loved the dynamic nature, the whitespace, the libraries, the whole nine yards. Convinced I would never need anything else, at least until I started looking for a half- decent web framework [2005 - ie pre- Django]. At which point I was casting envious glances over at Rails .. dammit, I was just going to have to learn Ruby as well.
And whilst it started out looking like a poor imitation of Python [who needs all these 'end' keywords ?], gradually it gets under your skin. You start to love writing ‘array.size’ rather than ‘len(array)’, or ‘-1.abs’ instead of ‘abs(1)’; and you start to wonder why Python needs all these keywords littered across the place. And when you finally figure out what code blocks and the Enumerable module are all about, you realise there will never be any going back.
Yeah, I know Python has list comprehensions, lambda functions etc; it’s just they feel much more of a hack if you’re used to Ruby’s code blocks.
So .. one up to Heroku for Ruby.
Framework
Rails [Heroku] versus .. hmm, something a little more bare-bones [AppEngine].
If you come from the Rails world than AppEngine presents you with something decidedly more stripped down. The familiar MVC structure is there [except in AppEngineLand they're called models, templates and scripts], but the overall feeling is that the structure is far more ’stripped down’ than Rails; it’s rather like working with Rails but without all the helpers.
For example if you’re working in the controller layer, there’s none of the nice Rails respond_to code that helps you differentiate between ‘Accept’ header requests; you have to build it yourself. There’s none of the code that helpfully parses HTTP parameters into easy-to-use Hash structures; you get some basic functions allowing you to query for parameters by name, and that’s about it.
Similarly at the persistence level; there are no ActiveRecord- style belongs_to/has_many relationships allowing you to define model relationships in a sexy way; you can do it [using Reference Properties]; it’s just it feels more basic.
And the wierd thing is .. I kind of like it. Though I think Rails is a wonderful beast, there are aspects of the helpers layer which really don’t seem to work to me .. leaky abstractions, I think Joel would call them. Such as being able to define belongs_to/has_many relationships at the model level, but still having to remember to defined a parent_id field at the database level. WTF ?! Talk about something poking through the abstraction layer! Either do this stuff for me properly, or not at all.
So .. a close call, but AppEngine wins here.
Persistence
Traditional relational database for Heroku, BigTable for AppEngine; old versus new.
It’s not quite that simple however as Rails’ ActiveRecord takes a lot of the pain out of dealing with the database; it’s the certainly cleanest ORM framework I’ve ever used; a lot of the time it really does feel like you’re dealing with an in-memory structure - no ‘database-iness’ at all.
Unfortunately, as I mentioned earlier, the abstraction leaks in a couple of places. You still have to manage your foreign keys manually. You also also can’t just make arbitrary changes to you database schema; you have to ‘migrate’ the database.
Now I can see what migrations are trying to achieve - give you a way to modify your schema whilst preserving your data - which is a worthwhile goal - but they also introduce an extra layer of complexity. I haven’t personally come across a situation where I needed to modify the schema in situ; I tend to mess with the schema in development [when the data doesn't matter] and then stick with that schema in production. So I tend to view Rails migrations as a layer I would rather do without.
And although the foundations of BigTable are decidedly un-relational, dealing with it at the developer level feels very like dealing with a migration-less Rails datastore. No, the ORM layer isn’t nearly as sexy or complete as ActiveRecord; but you benefit from being able to hack the database structure much more easily in development . No migrations to design, run and then manage; just simply add a column definition to your model.
Certainly more bare bones, but preferable in my opinion. Another win for AppEngine.
Tools
- Source Control. The Heroku API uses Git; if you use Heroku then your source code is living on Heroku with your app; there’s no choice here. AppEngine has no such restriction; you can keep your source code wherever you like [GitHub etc]. I have a marginal preference for the AppEngine model; I don’t really see why my source code should have to reside with my app; it’s nicer to have the option.
- Deployment. Pretty good in both cases - with Heroku you simply run ‘git push’ to push your source code / deploy your app; AppEngine has a custom script (appcfg.py) which you run to deploy your app. Not much to chose between them here.
- Database management. The yardstick here is Rails ’script/console’, which gives you an IRB shell right into the database in development mode - very nice. Until recently neither AppEngine or Heroku offered anything as clean as this; both have an HTML- based ‘interactive window’ into which you can enter code; they work, but it’s not very clean. But stop press! The new Heroku API has a shell command ‘heroku console’, which gives you direct access into your production database from the command line - exactly what the doctor ordered!
Given each platform is only 12-18 months old right now the tools are still fairly primitive; there’s a lot of room for improvement on both sides.
Verdict ? Draw.
Conclusion
Aaarghhh OK decision time. This is tricky. Truth is I like both of these platforms. There was a time, not so long ago, when deployment was *the* major headache for the small guy like me. Deploying Rails - Apache ? Mongrel ? FastCGI ? Lighttpd ? Total acronym soup. No concensus in the community about the right way to do it. A total nightmare. So bad, I almost considered moving to PHP (yuk) just to ease the deployment pain.
These platforms are the way out of that quagmire. Now you have a simple, pushbutton way of deploying Python and Ruby webapps, with the added promise of [relatively] painless scaling. They’ve both taken away a huge headache, and there’s a lot to like about each.
But we need a winner. So I’ve decided to plump for … Heroku! Why ? Dunno. Hard to call. Appengine won on a lot of the points above. I think at the end of the day it’s my simple preference for coding in Ruby over Python. Plus the recent deployment of the latest Heroku platform, which looks like a major leap forward. Perhaps in the end it’s a British preference for the plucky underdog over the 800 pound gorilla.
Whatever. They’re both worthy platforms and I hope [for my sake] they continue to prosper, innovate and breed new competition. Here’s to them both.
written by justin
\\ tags: appengine, django, heroku, python, ruby