注:经过调研发现,网络上对于此四者关系的描述不尽相同,有的甚至相差甚远,对于官方的一些资料及对比一些博客,得出以下认识,如有偏颇之处,望不吝指正。

用一张图可以清晰的展示四者的关系(此图摘自网络):

WSGI, uWSGI, uwsgi, nginx

1. WSGI

WSGI(Web Server Gateway Interface)即Web服务器网关接口,它不是任何软件,而是一种通信协议(PEP3333)。

The availability and widespread use of such an API in web servers for Python – whether those servers are written in Python (e.g. Medusa), embed Python (e.g. mod_python), or invoke Python via a gateway protocol (e.g. CGI, FastCGI, etc.) – would separate choice of framework from choice of web server, freeing users to choose a pairing that suits them, while freeing framework and server developers to focus on their preferred area of specialization.

This PEP, therefore, proposes a simple and universal interface between web servers and web applications or frameworks: the Python Web Server Gateway Interface (WSGI).

其目的是为了使框架和web服务器分离,使实现了WSGI的框架和web服务器可以自由搭配。

2.uWSGI

uWSGI是一个web服务器,实现了WSGI协议,这样它就可以和实现了WSGI协议的框架进行通信(PEP3333)。

3.uwsgi

uwsgi是一种线路协议而不是通信协议,在此常用于在uWSGI服务器与其他网络服务器的数据通信(如nginx)。uwsgi协议是一个uWSGI服务器自有的协议,它用于定义传输信息的类型。

4.nginx

一个高性能的web服务器

综上所述:WSGI是一种框架与web服务器间通信的协议,uwsgi是uWSGI与其他web服务器通信的协议,uWSGI是一个web服务器,也可以作为中间件使用,nginx是一个web服务器

相关文章: