Python
Smooth when warmed.
Sluggish if served cold.
Serving Python
At first glance...
- Python Native Web Server
- Application Container/Wrapper
Common Containers
- CGI
- Apache + mod_python
- FastCGI
- Apache + mod_wsgi
- uWSGI
http://docs.python.org/2/howto/webservers.html
WSGI
Web Server Gateway Interface
WSGI was created as a low-level interface between web servers and web applications or frameworks to promote common ground for portable web application development.
The Two Sides of WSGI
The WSGI has two sides: the "server" or "gateway" side, and the "application" or "framework" side.
WSGI middleware implements both sides of the API so that it can
intermediate between a WSGI server and a WSGI application performing utility functions:
-
Routing a request to different application objects based on the target URL.
- Allowing multiple applications or frameworks to run side-by-side in the same process
- Load balancing and remote processing, by forwarding requests and responses over a network
- Perform content postprocessing.
WTH is uWSGI Then?
The uWSGI project aims at developing a full stack for building hosting services. Application servers (for various programming languages and protocols), proxies, process managers and monitors are all implemented using a common api and a common configuration style. Thanks to its pluggable architecture it can be extended to support more platforms and languages.
Currently, you can write plugins in C, C++ and Objective-C.
The “WSGI” part in the name is a tribute to the namesake Python standard, as it has been the first developed plugin for the project.
Versatility, performance, low-resource usage and reliability are the strengths of the project (and the only rules followed).
Invocation
$ service myserver start | stop | status
/etc/init/myserver.conf
start on runlevel [2345] stop on runlevel [016] respawn pre-start script NUM_PROC=`nproc` NUM_PROC=`expr $NUM_PROC \* 4` end script script exec /usr/local/bin/uwsgi -s ws.sock -M -p $NUM_PROC -b 12288 -C 600 --pythonpath /myproject/ --wsgi-file /myproject/wsgi.py --gid www-data --uid www-data --need-app --stats 127.0.0.1:30001 --log-x-forwarded-for --memory-report --reload-on-rss 1024 --logger syslog:uwsgi-ws -l 1024
end script
Request Handling

Advanced Routing

Source
https://github.com/unbit/uwsgi
Documentation
https://uwsgi-docs.readthedocs.org/en/latest/
Serving Python with uWSGI
By jcwdev
Serving Python with uWSGI
Overview of uWSGI Application Container
- 1,059