Two methods for TornadoWeb server multi-process startup

Source: Internet
Author: User
This article mainly introduces two methods for multi-process startup of TornadoWeb server. Tornado is a WEB server written in Ptyhon. For more information, see I. INTRODUCTION to Tornado

Tornado is an open-source version of FriendFeed's Web server and common tools. Tornado differs significantly from the current mainstream Web server framework (including most Python frameworks): It is a non-blocking server and is fast. Tornado can process thousands of connections per second based on its non-blocking method and epoll application. Therefore, Tornado is an ideal framework for real-time Web services.

II. multi-process startup method

Normal start method:

The code is as follows:


Server = HTTPServer (app)
Server. listen (8888)
IOLoop. instance (). start ()

Multi-process, Solution 1:

The code is as follows:


Server = HTTPServer (app)
Server. bind (8888)
Server. start (0) # Forks multiple sub-processes
IOLoop. instance (). start ()

Multi-process, Solution 2:

The code is as follows:


Sockets = tornado. netutil. bind_sockets (8888)
Tornado. process. fork_processes (0)
Server = HTTPServer (app)
Server. add_sockets (sockets)
IOLoop. instance (). start ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.