Jeff is a DZone MVB and is not an employee of DZone and has posted 15 posts at DZone. You can read more from them at their website. View Full User Profile

Does Rails Scale?

10.15.2012
| 10415 views |
  • submit to reddit

First, the short answer: Damn right it does.

Twitter had to quit using it because Ruby is so slow

It is well known that around 2008 Twitter moved their job backend from Rails to Scala. To me it seems they absolutely made the right choice. Twitter had way outgrown the version of Ruby it was on and they needed a different solution.

Keep in mind that Ruby 1.9 came out a year later in 2009. The performance characteristics between 1.8 and 1.9 is huge. Just look at this graph from Zendesk's report of moving from 1.8 to 1.9

In addition, Rails had no support for asynchronous jobs at the time. Rails would not have done anything to help job processing, so moving to Scala probably made a lot of sense. Today, we have Resque and Sidekiq which make the process much cleaner on the code side.

But Ruby is slow even in 1.9

It's not a fast language. However, that rarely matters. The hard part about scaling an application is proper architecture, solid caching and CDNs, the right database for the job and so on. It's more about external resources than the code in the app. The runtime of the language rarely becomes an issue. The goal is to leverage existing tools in order to do less work on the web stack.

In most scenarios, you're scaling concern will not be waiting on the speed of Ruby, but the I/O. When Ruby is really able to leverage its fibers (such as in em-synchrony), we'll start to see node.js levels of performance.

None of this matters

I wouldn't call Twitter unsuccessful. They did build their product and eventually found the right architecture for them. I doubt the engineers at Twitter think that going with Scala right off the bat would've been the right choice. Using Rails, they could build the product quickly. They could change it in order to build the product in a way that was successful. Rails empowers the developers to change direction without a lot of code change.

Not only can developers alter features, but the same is true on the backend as well. I've worked on a system where we swapped database backends from MySQL to PostgreSQL with almost no code change. Another project where we included advanced caching layers without modifying existing models. In the same way that Ruby allows rapid product changes, the ability to rapidly alter architecture changes ensures scalability.

These are all changes that would've been so prohibitively difficult in my .NET and Django days that we would've just greenfielded a new project.

Rails is not all roses

While Rails does a lot of things well, there is one part of scaling it does not do well. The human issue. Rails encourages the 'monorail' architecture. Projects approach the size that become difficult to work on. No single engineer will understand the project from beginning to end. New engineers will be lost in the project and feel unproductive. Bugs might arise out of seemingly disconnected parts of the code-base.

A more disconnected architecture has many pros in a large system. Engineers will feel more productive as they can really own their project. The knowledge needed to be productive will be much lower.

Square, Groupon, YP, Tapjoy and others have all experienced these growing pains. They've also all moved to a service-oriented architecture (SOA) to solve these issues. One of the biggest issues Rails has is with easing that transition. Now that it's been happening regularly, I think we'll start to be able to identify patterns and enhance the framework to support it, however.

That doesn't mean you should go for SOA right off the bat though. I believe moving from a monorail and then breaking the system apart is the correct approach. With any platform, SOA is simply a more complicated architecture. You also won't know what services there actually should be until you've got a large codebase.

So yes, it does scale

Even given the faults on the monorail problem, Rails scales beautifully. Between the speed of Ruby 1.9, the fact that most of our work is I/O heavy, and the ability to alter the stack: it certainly scales.

 

 

 

Published at DZone with permission of Jeff Dickey, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Jonathan Fisher replied on Tue, 2012/10/16 - 11:03am

Really what this article said is, "No, it doesn't 'scale' per say, but that probably won't matter since anything that needs to be fast will be written in Java or CPP anyway."

Interesting argument :) I wish someone would invent something as simple as Flask for Java...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.