Twitter has become the poster child of why not to use Ruby on Rails. Recently a friend of mine started a company and when I noticed he used PHP I asked why he didn’t use Rails. He responded “Twitter uses Rails and they keep going down. Facebook uses PHP. We’ll use PHP.”
There is an interesting interview w/ Twitter developer Alex Payne about the issues Twitter has had with Ruby on Rails.
The common wisdom in the Rails community at this time is that scaling Rails is a matter of cost: just throw more CPUs at it. The problem is that more instances of Rails (running as part of a Mongrel cluster, in our case) means more requests to your database. At this point in time there’s no facility in Rails to talk to more than one database at a time. The solutions to this are caching the hell out of everything and setting up multiple read-only slave databases..
All the convenience methods and syntactical sugar that makes Rails such a pleasure for coders ends up being absolutely punishing, performance-wise. Once you hit a certain threshold of
traffic, either you need to strip out all the costly neat stuff that Rails does for you (RJS, ActiveRecord, ActiveSupport, etc.) or move the slow parts of your application out of Rails, or both.
It’s also worth mentioning that there shouldn’t be doubt in anybody’s mind at this point that Ruby itself is slow. It’s great that people are hard at work on faster implementations of the language, but right now, it’s tough. If you’re looking to deploy a big web application and you’re language-agnostic, realize that the same operation in Ruby will take less time in Python. All of us working on Twitter are big Ruby fans, but I think it’s worth being frank that this isn’t one of those relativistic language issues. Ruby is slow.
There are many large sites that run Rails well and many smaller ones that do not. It seems like another case of the “leaky abstraction” where we have such a nice framework that we think we can abstract away issues like scaling but in the end when the site becomes big enough we have to look under the covers.
Ruby has been documented to have I/O issues and general performance issues. Like PHP before it looks like Ruby needs to mature more and deal better with scaling and I/O issues. I am confident though this will happen because of the tremendous momentum of Ruby on Rails. However I am keeping on eye on Django, especially now that Google has thrown its large hat into Django’s ring.