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.
In April 2007, former Chief Architect Blaine Cook made a presentation called Scaling Twitter.Â It’s a well done presentation, even if everything is black.
In May 2008 there were rumors that Twitter was abandoning Rails.Â SitePoints believes it is not a framework issue but rather an architectural issue that is causing Twitter’s problems.
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.