Forgot your password?
typodupeerror
Programming Software IT Technology

Twitter On Scala 324

Posted by kdawson
from the going-off-the-rails dept.
machaut writes "Twitter, one of the highest profile Ruby on Rails-backed websites on the Internet, has in the past year started replacing some of their Ruby infrastructure with an emerging language called Scala, developed by Martin Odersky at Switzerland's École Polytechnique Fédérale de Lausanne. Although they still prefer Ruby on Rails for user-facing web applications, Twitter's developers have started replacing Ruby daemon servers with Scala alternatives, and plan eventually to serve API requests, which comprise the majority of their traffic, with Scala instead of Ruby. This week several articles have appeared that discuss this shift at Twitter. A technical interview with three Twitter developers was published on Artima. One of those developers, Alex Payne, Twitter's API lead, gave a talk on this subject at the Web 2.0 Expo this week, which was covered by Technology Review and The Register."
This discussion has been archived. No new comments can be posted.

Twitter On Scala

Comments Filter:
  • by digitig (1056110) on Tuesday April 07, 2009 @05:03PM (#27495675)
    Really? Try comparing the scalability of, say, FORTRAN or COBOL against any modern language with decent encapsulation.
  • There you go again! (Score:5, Informative)

    by Jane Q. Public (1010737) on Tuesday April 07, 2009 @05:18PM (#27495909)
    Ruby does not have a problem scaling. Neither, for that matter, does even Rails. (As the companies that run Basecamp, Campfire, LinkedIn, Lighthouse, and many others will tell you.)

    The fact is that the Twitter folks tried to write their own message queue in Ruby [unlimitednovelty.com], when there was absolutely no reason to do so: there were plenty of pre-made message queues already available for Ruby, and already optimized. Not only did they choose to write their own, unnecessarily, they did it badly [obiefernandez.com].

    And not only that, but Alex Payne has a hidden agenda: he is trying to push Scala to boost interest in the book about Scala he just wrote! [obiefernandez.com]

    Please get some facts before digging up this long-dead and well-buried "Ruby or Rails doesn't scale" bullshit again.
  • by tieTYT (989034) on Tuesday April 07, 2009 @05:18PM (#27495915)

    http://unlimitednovelty.com/2009/04/twitter-blaming-ruby-for-their-mistakes.html [unlimitednovelty.com]

    This blog post takes the attitude that Twitter didn't move to Scala because ROR had a problem, but because the in-house messaging system Twitter created performed poorly. The author does not work at Twitter but many of the Twitter developers (including Alex Payne) respond in the comments. I found the article to be very interesting and the comments even more so. They give a sense of how much research Twitter did before this change.

  • by Anonymous Coward on Tuesday April 07, 2009 @05:41PM (#27496203)
    PHP on the backend is as bad if not worse than Ruby (probably more in the worse category). It does not even have threading built in. Try building a php messaging queue and let me know how that goes. Facebook does not use PHP on the backend anymore than twitter was using Ruby for it. They have a ton of different stuff in many languages. I don't think you get what they are trying to do with Scala.
  • by Bruce Perens (3872) * <bruce@perens.com> on Tuesday April 07, 2009 @05:46PM (#27496279) Homepage Journal
    This is the same for Ruby. You can create a list, or you can create some object you wrote in hand-optimized C which just responds to the same operations as a list.
  • Re:Proving that.. (Score:4, Informative)

    by burris (122191) on Tuesday April 07, 2009 @05:57PM (#27496425)

    According to the rebuttals in the comments of the blog post in one of my sibling posts here, part of Twitter's scalability problem was poor implementation of the Ruby interpreter. Lots of small objects cause the heap to get fragmented and eventually it runs out of memory. Java interpreters have better GC and you can swap out different GC algorithms in some of them.

    Why does everyone assume the people at Twitter are a bunch of newbies who don't know about deep engineering? Is it just because their analysis didn't lead them to your preferred buzzword?

  • by caramelcarrot (778148) on Tuesday April 07, 2009 @06:34PM (#27496839)
    Facebook doesn't use PHP for the backend, it's mostly C++, Python and Erlang.
  • by moderatorrater (1095745) on Tuesday April 07, 2009 @06:38PM (#27496877)
    Not a single site you posted is anywhere near the volume of traffic that Twitter's seen. Hulu's the closest, but the heavy lifting is done outside of RoR.
  • by Trepidity (597) <delirium-slashdo ... org minus author> on Tuesday April 07, 2009 @07:12PM (#27497187)

    It depends partly on what your concurrency looks like. Erlang supports one model of concurrency, a lightweight message-passing one with no explicit threads or shared memory. Scala supports that one as well---less efficiently---but also supports standard Java multithreading, which some people find useful for some purposes.

  • by hhr (909621) on Tuesday April 07, 2009 @08:04PM (#27497693)

    The article is about Ruby on Rails. Ruby on Rails is not just a langauge. It is a lanaguage and a web framework. Frameworks very much affect your scalability.

  • by DuckDodgers (541817) <keeper_of_the_wolf AT yahoo DOT com> on Tuesday April 07, 2009 @08:05PM (#27497701)
    Scala has the significant advantage that it's built on Java and interoperable with Java. Scala source code compiles directly into .class files. You get the speed of the JVM (which is acceptably quick these days), the ability to easily call Java APIs from within Scala, and the ability to run your Scala code on any machine with the JVM.

    It's popular to dislike Java, and even as a well paid Java developer I'm not a huge fan of the language. But Java still is extremely common, and you can even write Java code for your Scala code to use while you're learning Scala.

    Scala also keeps Java's strong static typing and adds functional language features. I don't think it needs any development at all to be adapted for mainstream use.

    On the other hand, as a C++ developer I found learning Java to be child's play. The learning curve from Java to Scala, for me at least, is noticeably steeper. If anything kneecaps Scala I suspect it will be the barrier to entry, not the language itself.
  • by tieTYT (989034) on Tuesday April 07, 2009 @08:38PM (#27497981)

    Jane Q. Public: Either you didn't read the comments of that blog or you're spreading FUD. Here is a comment from Alex Payne from that article:

    Hoo boy. First of all, I hope you've had a chance to read my general reply to the articles about my Web 2.0 Expo talk [1] and this response to a vocal member of the Ruby community [2]. I sound like a pretty unreasonable guy filtered through the tech press and Reddit comments, but I hope less so in my own words.

    Secondly, the quote at the top of your post is from my coworker, Steve Jenson, who's been participating in the discussion on this post.

    On JRuby: as Steve said, we can't actually boot our main Rails app on JRuby. That's a blocker. Incidentally, if you know of anyone who has a large JRuby deployment, we'd be interested in that first-hand experience. If you don't, it might be a little early to say it would solve all our problems.

    It's also incorrect to say that the way JRuby and Scala make use of the JVM is exactly the same. Much like our other decisions haven't been arbitrary, our decision to use Scala over other JVM-hosted languages was based on investigation.

    On our culture: if you'd like to know about how we write code, or how our code has evolved over time, just ask us. We're all on Twitter, of course, but most of the engineers also have blogs and publish their email addresses. There's no need to speculate. Just ask. There's not a "raging debate" internally because we make our engineering decisions like engineers: we experiment, and base our decisions on the results of those experiments.

    It's definitely true that Starling and Evented Starling are relatively immature queuing systems. I was eager to get them out of our stack. So, as Steve said, we put all the MQ's you think we'd try through their paces not too long ago, and we knocked one after another over in straightforward benchmarks. Some, like RabbitMQ, just up and died. Others chugged on, but slowly. Where we ran into issues, we contacted experts and applied best practices, but in the end, we found that Kestrel fit our particular use cases better and more reliably. This was not the hypothesis we had going into those benchmarks, but it's what the data bore out.

    We get a lot of speculation to the tune of "why haven't those idiots tried x, it's so obvious!" Generally, we have tried x, as well as y and z. Funnily enough, I was actually pushing to get us on RabbitMQ, but our benchmarks showed that it just wouldn't work for us, which is a shame, because it advertises some sexy features.

    Personally, I'm extremely NIH-averse; I research open source and commercial solutions before cutting a new path. In the case of our MQ, one of our engineers actually wrote Kestrel in his free time, so it was bit more like we adopted an existing open source project than rolled our own. Pretty much the last thing we want to be doing is focusing on problems outside our domain. As it so happens, though, moving messages around quickly is our business. I don't think it's crazy-go-nuts that we've spent some time on an MQ.

    I hope my colleagues and I have been able to answer some of your questions. As I said, in the future, please consider emailing us so we can share our experience. Then, we can have a public discussion about facts, not speculation. Perhaps, as commenter sethladd suggested, the onus is on us to produce a whitepaper or presentation about our findings so as to stave off such speculation. Time constraints are the main reason why we haven't done so.

    [1] http://al3x.net/2009/04/04/reasoned-technical-discussion.html [al3x.net]
    [2] http://blog.obiefernandez.com/content/2009/04/my-reasoned-response-about-scala-at-twitter.html#IDComment18212539 [obiefernandez.com]

  • scala vs erlang (Score:3, Informative)

    by xkcd150 (1527245) on Wednesday April 08, 2009 @02:17AM (#27500159)
    i figured a lot of people would mention erlang, and thought someone might be interested in this writeup i read the other day http://yarivsblog.com/articles/2008/05/18/erlang-vs-scala/ [yarivsblog.com]

"Hello again, Peabody here..." -- Mister Peabody

Working...