How Twitter Scaled Up

by nmac. Average Reading Time: about a minute.

How Twitter Scaled Up

While I was working at Ritsumeikan APU in Japan, our web infrastructure was letting down the students and the Prof’s that used the web based course tool in anger.
The problem was the spike.
At the start of every lecture, or worse, the start of web based tests and examinations, literally hundreds of students would hammer the web servers, and quickly the number of threads would get swallowed up and port 80 would drag to a crawl.

Even though the servers were big grunty enterprise boxes from Sun Microsystems, loaded with RAM, and with Apache and the backend Oracle database highly tuned, it just could not handle to spike in demand. It was one of those few times that Microsoft came to the rescue with a bridgehead load balancing server that directed requests back to the farm of webservers, and spread the load evenly.

I was reminded of this recently while learning a bit more about Scala, a not so-often heard programming language that is behind some of the biggest Web Infrastructures out there today. Ever wondered how Twitter is able to cope with the staggering volume of tweets that are broadcast every second?

Yes. Key parts of Twitter are written in Scala.

Ruby was just not cutting it, and a rewrite in Scala solved a lot of problems.

There is an interesting conversation over on www.artima.com about it, and you’ll learn a lot more about Scala too. Anyone with a Unix admin background will smile as they learn about the pattern matching side of the language – remember awk. Love it. I’m guessing we will be hearing more about scala in the next year – full .Net support as well as JVM. Could this be the next big thing?

There is a fun little overview slideshow by a Twitter Developer Alex Payne here too: http://www.slideshare.net/al3x/why-scala-presentation