WSGI 、uwsgi、uWSGI、Nginx、flask在整个web程序访问中的作用和位置

WSGI: Web Server Gateway Interface,web服务器网关接口,一种描述web服务器(如nginx,uWSGI等服务器)如何与web应用程序(如用Django、Flask框架写的程序)通信的规范。

WSGI is a specification. uWSGI provides an implementation of the WSGI specification. WSGI是一种规范。uWSGI提供了WSGI规范的一种实现


1. WSGI and uwsgi both ARE protocols, not servers. It is used to communicate with web servers for load balancing and especially to take advantage of extra features that pure HTTP can not provide. So far Nginx and Cherokee have implemented this protocol.
2. uWSGI is a server and one of the protocols it implements is WSGI (do not confuse the uwsgi protocol with the uWSGI server). WSGI is a Python specification. There are several implementations of the WSGI specification and it's intended to be used for more than just application servers/web servers, but there are quite a few WSGI application servers (ie. CherryPy, which also happens to have a production ready WSGI compliant web server, if you weren't confused enough already!).
3. Comparing uWSGI to WSGI is comparing oranges to apples.
It is generally best to run Python in a separate process from your main web server. That way, the web server can have lots of tiny threads that serve static content really fast, while your separate Python processes will be big and heavyweight and each be running their own Python interpreter. So plain WSGI is bad, because it bloats every single one of your nginx threads with a big Python interpreter. Using flup or gunicorn or uWSGI behind nginx is much better, because that frees up nginx to simply serve content, and lets you choose how many tiny light nginx threads to run, independently of your choice of how many heavyweight Python threads you bring up to serve dynamic content. People seem very happy with gunicorn at the moment, but any of those three options should work fine.
Going forward, it also frees you up to move the Python to another server when load starts to get serious






QR Code
QR Code wsgi_uwsgi_nginx_flask在整个web程序访问中的作用和位置 (generated for current page)