BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Twitter’s Shift from Ruby to Java Helps it Survive US Election

Twitter’s Shift from Ruby to Java Helps it Survive US Election

Leia em Português

This item in japanese

Lire ce contenu en français

Bookmarks
Twitter's infamous Fail Whale was absent on US presidential election day, even as Twitter's servers were handling a serge of 327,452 tweets per minute, according to Mazen Rawashdeh, Twitter's VP of Infrastructure Operations Engineering. In total, there were 31 million election-related tweets during the course of the day, and the traffic continued to periodically spike - at one point reaching 15,107 tweets per second. To put this figure in context, on the 2008 election night Twitter peaked at 229 tweets per second.

Rawashdeh notes that Twitter has been seeing a change in usage pattern over the last year from brief spikes (for example related to the clock striking midnight on New Year’s Eve or a celebrity pregnancy announcement) to more sustained peaks of traffic lasting several hours. This occurred, for example, during the Olympics closing ceremony, the NBA finals, and now with the election.

Part of the reason Twitter was able to sustain this level of traffic was down to a set of changes the company has been making to their infrastructure, including, as InfoQ previously reported, a gradual shift away from Ruby to a set of services written in a mixture of Java and Scala and running on the JVM.

The most recent reported change was for Twitter's mobile clients. Rawashdeh wrote

As part of our ongoing migration away from Ruby we've reconfigured the service so traffic from our mobile clients hits the Java Virtual Machine (JVM) stack, avoiding the Ruby stack altogether.

Twitter was at one time thought to be the largest Ruby on Rails shop in the world, and has made a substantial investment in its Ruby stack, going as far as developing its own generational garbage collector for Ruby called Kiji, which, unlike the standard Ruby collector, divides objects into generations and, on most cycles, will place only the objects of a subset of generations into the initial white (condemned) set.

In 2010, however the firm announced that it was shifting some of its development focus. For the front-end the firm followed the HTML5 trend of shifting rendering code into browser-based JavaScript, and, in so doing, it ceased to gain much benefit from Rails' templating model for building web pages. Then, citing both performance and code-encapsulation as drivers, the engineering team re-wrote both its back-end message queue and tweet storage engine in Scala.

Also in 2010, the search team at Twitter started to rewrite the search engine, changing search storage from MySQL to a version built on top of Lucene. Then in 2011 the engineering team announced that they had replaced the Ruby on Rails front-end for search with a Java server they called Blender. This resulted in a 3x drop in search latencies.

As a result of these changes Twitter's system stayed running without problems. "The bottom line: No matter when, where or how people use Twitter, we need to remain accessible 24/7, around the world," wrote Rawashdeh. "We’re hard at work delivering on that vision."

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Not a brainier

    by Mileta Cekovic,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Not a brainier that JVM language will be faster then native Ruby.
    Building such a big infrastructure for such a big service as Twitter in Ruby was a big mistake. Not that Ruby is bad, simply not for that scale, good for many purposes, but not for large scale systems.

  • Credit goes to JVM developers

    by peter lin,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    I think the real credit goes to the people that worked on the JVM and made it rock solid, and efficient. If it wasn't for that, it wouldn't really which language twitter used. It helps that guys like Clif Click made the JVM what it is today.

  • Re: Credit goes to JVM developers

    by Cameron Purdy,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Java was very lucky that Sun had such great engineers. Thankfully, a few of them are still around ;-)

  • Any relative comparisons?

    by Roopesh Shenoy,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Any idea where twitter usage stands compared to other heavily used apps such as Facebook and Google? I can see that the loads might also be different types (for e.g. heavy writes vs reads for Google) but some comparisons of throughput achieved, hardware needed, spikyness, etc. with their respective strategies should be interesting to see.

  • Obie vs. JVM

    by Fred Daoud,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Where are you now, Obie Fernandez, claiming that it was FUD to say that Ruby/Rails does not scale well?

  • Re: Not a brainier

    by sreeni k,

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Point to make here that twitter ran very well on ruby till now. Kudos for adopting a new language and proving that it works so far. Not every application has the traffic like twitter hence its not the end of the world for ruby. Regards sreeni www.sreenivaskandakuru.com

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT