New Tweets Per Second Record, And How!
A primary goal at Twitter is to make sure the service is always available no matter what is happening around the world.
This goal felt unattainable in 2010 with Ruby, when the World Cup put Twitter squarely in the center of a real-time, global conversation. Learn how Twitter re-architected its site using Scala to make sure their service is resilient to the world’s impulses.
Since its inception, Twitter had run on software built with a computer programming tool called Ruby on Rails — a tool that played a huge role in the web’s resurgence in the middle of the decade, letting engineers build sites so quickly and easily. But Twitter’s engineers came to realize that Ruby wasn’t the best way to juggle tweets from millions of people across the globe — and make sure the site could stay up during its headline moment with the president of Russia.
Scala is one of the main application programming languages used at Twitter. Much of our infrastructure is written in Scala and we have several large libraries supporting our use. While highly effective, Scala is also a large language, and our experiences have taught us to practice great care in its application. What are its pitfalls? Which features do we embrace, which do we eschew? When do we employ “purely functional style”, and when do we avoid it? In other words: what have we found to be an effective use of the language? This guide attempts to distill our experience into short essays, providing a set of best practices. Our use of Scala is mainly for creating high volume services that form distributed systems — and our advice is thus biased — but most of the advice herein should translate naturally to other domains. This is not the law, but deviation should be well justified.
It wasn’t going to be easy to get our performance, reliability, and efficiency goals out of the Ruby VM, so we embarked on writing code to be run on the JVM instead. There was a level of trust that we all had in the JVM. We were confident we could pull off a sea change for Twitter in the world of the JVM. We estimated that rewriting our codebase could get us > 10x performance.Raffi KrikorianVP, Platform Engineering, Twitter
Inspired by this story? Contact us to learn more about what Lightbend can do for your organization.