Facebook Open Sources ‘Tornado’ the Engine That Drives FriendFeed

When Facebook acquired FriendFeed back in August, the big question was, what would Facebook do with FriendFeed? While that question remains up in the air, Facebook has done something with the code that powers FriendFeed, namely, released it as an open source framework.

Tornado, as the new, Python-based web framework is known, is designed specifically to handle the massive server loads of FriendFeed’s real-time updates. By releasing Tornado as open source, Facebook is giving developers a way to use FriendFeed’s core infrastructure in their own real-time web projects.

While most large scale web services, for example Twitter, have had trouble scaling as their user base grows, FriendFeed managed to avoid most of those problems, which makes Tornado all the more appealing to developers looking to build the next generation of real-time web apps.

Under the hood Tornado looks a bit like other Python frameworks such as Django or web.py, but specializes in handling concurrent connections — the sort of thing you need to build a news aggregator, real-time chat app or your own version of FriendFeed or Twitter.

The FriendFeed developers have benchmarked Tornado handling over 8,000 requests per second when run as four load-balanced processes (behind Nginx) on a four core server. Compare that to Django, which can handle only about 2200 requests per second on the same hardware setup. Tornado’s impressive capabilities are the result of its non-blocking architecture and its use of epoll to handle thousands of simultaneous standing connections

Tornado also comes with all the basic building blocks you’d typically need for a social network site — user authentication, cross-site request forgery protection, templates, signed cookies, localization, aggressive static file caching and more.

Tornado follows in the footstep of web.py and Django as a loosely coupled framework — you can use only what you want and mix in other Python libraries as the need arises. In other words, Tornado is not an all or nothing framework.

Bret Taylor, one of the co-founders of FriendFeed, has more details on what makes Tornado tick. If you’d like to see Tornado in action, head over to the real-time chat application which makes an impressive demo of Tornado’s power.

So what can you do with Tornado? Well, if you’re developing any sort of real-time web app we strongly suggest giving Tornado a look. While it seems that at a certain point just about any framework will fail and you’ll be forced to write a custom solution, Tornado’s real-world experience at FriendFeed means that it may well get you farther down the path to becoming the next Twitter than most frameworks.

Tornado is available under the Apache open source license and can be downloaded from the new Tornado website (documentation and sample code are available here).

See Also: