What is Tornado


Tornado is an open source version of the scalable, non-blocking web server and related tools used by FriendFeed. This web framework looks a bit like web.py or Google's webapp, but it also includes some useful tools and optimizations to make efficient use of a non-blocking server environment.

Tornado has a distinct difference from today's mainstream web server frameworks (including most Python's): it's a non-blocking server, and it's fairly fast. Thanks to its non-blocking approach and use of epoll, Tornado can handle thousands of connections per second, which means Tornado is an ideal web framework for real-time web services. We developed this web server primarily to handle FriendFeed's real-time functionality - every active user in a FriendFeed application maintains a server connection. (See the C10K problem on how to scale the server to handle thousands of client connections.)

See the Tornado documentation or Tornado original documentation (mirror) for details on the web framework.

Download and Install

Automatic Installation: Tornado is listed on PyPI, so it can be installed via pip or easy_install. If you don't have libcurl installed, you need to install it separately on your system. See the Installation Dependencies section below. Note that Tornado installed using pip or easy_install does not include the demo program in the source code.

Manual installation: download tornado-1.2.1.tar.gz
tar xvzf tornado-1.2.1.tar.gz
cd tornado-1.2.1
The code for python setup.py build
sudo python setup.py install

Tornado is hosted on GitHub. For versions of Python 2.6 and above, since the standard library already includes support for epoll, you can compile and install without setup.py, just simply add the directory of tornado to PYTHONPATH and you can use it.

Installation Requirements

Tornado has been tested in Python 2.5, 2.6, 2.7. To use all the features of Tornado, you need to install PycURL (version 7.18.2 or later) and simplejson (only for Python 2.5, JSON support is already included in the standard library after 2.6). For convenience, the complete installation on Mac OS X and Ubuntu is listed below:

Mac OS X 10.6 (Python 2.6+)
sudo easy_install setuptools pycurl

Ubuntu Linux (Python 2.6+)
sudo apt-get install python-pycurl

Ubuntu Linux ( Python 2.5)
sudo apt-get install python-dev python-pycurl python-simplejson

Hello, world

Here is the classic "Hello, world" example:
import tornado.ioloop
import tornado.web

class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.write("Hello, world")

application = tornado.web.Application([
    (r"/", MainHandler),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

See Tornado documentation to learn more about this web framework.

Discussion and Support

You can discuss and file bugs on the Tornado developer mailing list. You can also find more resources on the Tornado wiki.


Tornado is one of Facebook's open source technologies, released based on Apache Licence, Version 2.0.

This site and all its documentation is published under Creative Commons 3.0.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326655875&siteId=291194637