Rolling on Rails: Under the Hood at Twitter

By ‎@al3x‎

There’s been a lot of interest in how things run under the hood here at Twitter. If you’re one of the curious, join me for a geeky interlude.

Twitter started out on Rails because it’s the best framework for a rapidly evolving web application. We’ve never had more than three engineers working on Twitter since its inception, and with that small team we’ve managed to accomplish a ton thanks to the elegance of Ruby and the power of Rails. We can happily say that neither Ruby nor Rails will be out of the Twitter picture any time soon. We stand by the superb engineers at Powerset in saying that “Ruby as a whole is ready for the big show.”

We hit some scaling stumbling blocks a few months back, but not because Ruby or Rails was working against us. Once Twitter reached a certain amount of traffic we were forced to rethink our architecture; you don’t build a messaging system the same way you build a content management system. We set about developing custom solutions both inside and outside our Rails application. We also made good use of web scaling standbys: caching, database optimization, more hardware, and shared experience. Throughout this scramble to scale, Ruby and Rails were assets for their speed of development and creative, helpful communities.

For stressed engineers, it’s tempting to think that another solution - anything but what you’re using now! - will solve all your problems. Maybe you start dreaming up the perfect framework on a whiteboard, or maybe you start scouring the web for the fastest, newest, most experimental technology. In the long run, picking a foundation you’re comfortable with and making sensible iterations towards your performance goals will yield a bigger win. You have to be careful while iterating: watch your database, test thoroughly, and be ready to roll back when things break (and they will).

With great tools, constant learning, and hard work, you can be successful without reinventing the wheel. Rails is our chosen wheel, and we’re rolling right along with it. If you’d like to know more about our successes with Ruby and Rails, check out our presentations from the Silicon Valley Ruby Conference 2007 and RailsConf 2007. We hope to have some code to share along with our experience in the near future.