2 ways to Tornado Web server multi-process startup _python

Source: Internet
Author: User

Introduction of Tornado

Tornado is an open source version of the FriendFeed Web server and its common tools. Tornado is clearly different from the current mainstream WEB server framework (including most Python frameworks): It is a non-blocking server and is very fast. In its non-blocking manner and its use of epoll, Tornado can handle thousands of connections per second, so Tornado is an ideal framework for real-time WEB services.

Two, multi-process startup method

Normal Startup method:

Copy Code code as follows:

Server = Httpserver (APP)
Server.listen (8888)
Ioloop.instance (). Start ()

Multi-process, Scenario 1:

Copy Code code as follows:

Server = Httpserver (APP)
Server.bind (8888)
Server.start (0) # forks multiple sub-processes
Ioloop.instance (). Start ()

Multi-process, Scenario 2:

Copy Code code 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.