Will Ruby and Rails Scale?

"Can Ruby on Rails scale when my web traffic takes off like a rocket ship?" This is a common question we get (or some variation). I have a simple answer: "Yes, it can." As with any technology or framework, it's easy to build something that won't scale. Furthermore, there are applications where Ruby/Rails isn't the right solution. However, we believe that Rails will scale fine if you make smart architecture decisions. Heavily-used apps like Basecamp and large-scale sites like Revolution Health show this; but, lately people like to talk about Twitter's problems. Silicon Valley-based Powerset just announced that they're building their front-end in Ruby (though not necessarily Rails). They addressed the question of scaling and Twitter's situation with some first-hand insight:
We're not worried about scaling.
So, inevitably, whenever we talk about Ruby or Rails scaling these days, someone brings up Twitter and its scaling problems in the past. Twitter is right down the block from our offices and I know several of the devs personally, so before we made a final decision I arranged a sit down with Twitter's lead developer, Blaine Cook, to talk about the situation. Blaine was kind enough to let me bring along our Search Architect (and former search architect at Yahoo!) Chad Walters, our Head of Product Scott Prevost, and our COO Steve Newcomb, to poke and prod and get their questions answered. The simple fact is that Ruby wasn't the source of Twitter's woes. As it often happens with rapidly-growing sites, they ran into architectural problems. Some design decisions don't hurt until they reach a massive scale and, at that point, you have to rethink your approach. In an email he writes:

For us, it's really about scaling horizontally - to that end, Rails and Ruby haven't been stumbling blocks, compared to any other language or framework. The performance boosts associated with a "faster" language would give us a 10-20% improvement; but, thanks to architectural changes that Ruby and Rails happily accommodated, Twitter is 10,000% faster than it was in January.

Twitter's explosion of growth in March certainly created pain points for them (gotta love slide 7 here) and a lot of lessons learned; but, it's not an indication that the framework inherently won't scale. Our belief is that when building a web app, agility is more important that built-in scalability. "Premature optimization" causes more problems than it prevents. Focus on building a site that people will really use, then refactor and optimize over time as your audience grows. Rails is made for agility. You always hear about development speed, but test-driven development is easier and faster in Rails as well. Both factors mean that making architecture improvements to an already-deployed site is more practical. Regardless of technology, build with scaling in mind, not necessarily built-in. Friendster didn't scale, but that seemed to be a management decision. Had Twitter obsessed about trying to build for the number of users it's supporting today, they probably never would have made it out of the gates. And then how would I possibly know that Darth Vader just ate a burrito?

Brian is Viget's co-founder and CEO. He does everything from advising our clients to building our conference tables with his bare hands in our Falls Church, VA, HQ.

More posts by Brian