Need a Robust API? Try Scala

This guest post comes from Martin Odersky, Chairman and Chief Architect of Typesafe and creator of the open source Scala programming language. Follow Typesafe and Martin on Twitter.

Having an API allows a web application to foster interaction among a developer ecosystem that can bring innovation and unexpected connections to data sources that can take a web application from good to great. A robust API gives developers the opportunity to leverage business partners by opening their systems and data to a potentially huge group of other developers that have the time and resources to make things better, further entrenching an application into the lifestyles of millions of web users. One only has to think about the Tweet button on millions of web pages or Google’s +1 button, applications that ultimately aim to accomplish what some of the most successful web applications have done: become ubiquitous on the web.

Once a web application hits the holy grail of having millions of users hit its API, however, developers must become cognizant of performance issues that can bog down the User Experience. With this in mind, Scala is a robust language aptly suited for applications that can truly scale up and scale out. Some of the world’s most successful web applications have written their API in Scala because it provides first class support for functional programming, which discourages the use of mutable state. This allows applications to more easily scale hundreds of cores on a single server, and thousands of servers on a network.

An example of a successful web application that has written their API in Scala and boosted performance is Klout, a massively popular web application that has become the standard when measuring influence online. After seeing calls to the Klout API surge beyond ten billion per month, Klout’s developer team needed to re-engineer the API to sustain its rapid growth and massive traffic—now at 30 billion API calls per month—and to also empower its clients with all the features currently available on

The developer team at Klout chose the Play Framework technology Stack built on Scala for its powerful, easy to extend infrastructure, its fast non-blocking IO, and its stateless model that makes horizontal Scaling incredibly easy. What’s more, with a relatively small developer team and booming API calls, Klout needed efficient technology that boosted productivity above and beyond what they had before.

Foursquare is another fast growing web application poised to become the next "breakout hit.” Foursquare provides a cross between a friend-finder, a social city-guide and a game that rewards you for doing interesting things. With over 20 million people using the service worldwide, foursquare engineer lead Harry Heymann decided to move all the services to a Scala foundation. In just three months, foursquare moved their desktop and mobile websites as well as their REST API to Scala.

The LinkedIn Web site was launched in 2003 and is now the largest professional networking site in the world with more than 65 million members, representing 200 countries and executives from every Fortune 500 company. Chris Conrad, Engineering Manager for LinkedIn’s Social Graph, an application represented by more than 65 million nodes and 250 million request per day, explains that their People Search Engine receives around 15 million queries a day, or 250 queries per second with up to 100 tokens per query. These queries are all satisfied with a framework written in Scala that makes routing and Resource management a reliable 24x7 operation.
The above examples point to the need for today’s APIs to be robust and efficient as more of society shifts its everyday interactions online and more applications become pervasive across the web. Fundamental advances in programming languages like Scala are making it possible for web application developers to stay ahead of the scalable computing needs of consumers, thus enabling the huge API call numbers we’re seeing to some of the world’s most trafficked web applications.

Be sure to read the next Best Practices article: Twitter API Best Practices: Server vs. Browser API Processing