-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Deployment
Most Tornado apps are run as single processes. For production, there are no officially endorsed/preferred ways of managing your Tornado deployments, however this page will recommend and gather some best practices.
When debug mode is enabled, templates are not cached and the app will automatically restart during development. This will fail if a Python syntax error occurs, however. (This can be worked around w/ some additional code or by using Supervisor in development)
You might want to run your app from a terminal multiplexer like screen or tmux for more flexibility in leaving things running and tracing fatal errors.
Typically in production, multiple tornado app processes are run (at least one per core) with a frontend proxy. Tornado developer bdarnell has a tornado-production-skeleton illustrating this using Supervisor (process management) and nginx (proxying).
Traditionally, Tornado apps are single-process and require an external process manager, however HTTPServer can be run with multiple processes. Additionally, there are a couple additional helpers for helping out with managing multiple processes.
- Managing multiple Pylons apps with Supervisor - an excellent tutorial for getting started with Supervisor
- Deploy tornado application - short tutorial w/ Supervisor and nginx setup walkthrough
- supervisord-example.conf - this is an example cfg for running 4 tornado instances
- Nginx Supervisod Module - this module allows nginx to start/stop backends on demand
- Deploying Python web (Tornado) applications to multiple servers - short discussion on using a Load Balancer for live migration w/o downtime
- start-stop-daemon example - if you are running a standard Linux system this is an easy way to daemonize your Tornado app
Recently multi-process serving has been Most Tornado apps are single-process Traditionally, Tornado apps are single-processes that are managed by an external process manager
The official docs includes an example for running nginx as a load balancing proxy and for serving static files. *