Thursday, May 1, 2008

Does Django really scale better than Rails?

I do quite a bit of Rails work. A very good bit actually...perhaps 60% of my professional time is now spent on Rails.

I like it, but have heard horror stories regarding Rails scaling. I personally haven't run into any problems, but most of our applications run internally at businesses serving hundreds of users...not many thousands or millions.

I recently read an article on about a Rails-based Facebook app that was serving up 300 million page views monthly. The article describes (and touts) the way they've scaled the application across 12 servers:
- 4 DB servers, 6 application servers, 1 staging server, and 1 front end server.
- 6, 4 core 8 GB application servers.
- Each application server runs 16 mongrels for a total of 96 mongrels. -
- 4 GB memcache instance on each application server
- 2 32GB 4 core servers with 4x 15K SCSI RAID 10 disks in a master-slave setup
Holy crap Batman...that's a lot of iron. I did a double take when I saw this....I mean, I know 9.6 million requests a day is a lot, but this is a very simple application...a Facebook toy...not what I would consider representative of a significantly complex web application (please someone correct me if I'm wrong). I mean, if 12 servers were used to serve up something like Facebook itself, I'd understand, but a widget for Facebook? Something smells.

Again, I'm no scaling expert, and I'm perhaps a little bitter that I've never had written an app that generated 9.6 mil page views daily, but that's beside the point. To me, what this says is that Rails may scale, but you'd better have lots of cash on hand to do so. Please, if this is expected of an app with this many hits, beit PHP or Java or Perl or Python or Ruby, please let me know.

While living in Ruby camp for the past several years, one common drum I hear thumping from the Python camp is that fact that Python, and particularly, Pylons and Django, are superior from a scaling perspective. However, while researching this today, I've had a hard time coming up with cold hard facts. I'm working on a small app I'd like to dream will catch on one day, and I'm considering ridding myself of the scaling problems early by switching to Django; that is, if Django really avoids the problems Rails faces.

I can't find any articles stating that it does (supported by facts and figures), nor can I find examples of heavily hit applications in the wild and what they're using. I do realize that the Washington Post uses Django, but I've also read that it's not used pervasively and mainly for smaller, lower-traffic sections of the site.

So, help a Python/Django newb there something inherently better about Python versus Ruby, or Django versus Rails, that makes the first scale and perform better than the latter?

Thanks guys. I appreciate your continued patience and commentary.