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 ()