WSGI Divided into two parts : A for “ The server ” or “ gateway ”, The other is “ Applications ” or “ Application framework ”. Dealing with a WSGI When asked , The server will provide environment information and a callback function for the application (Callback Function). When the application finishes processing the request , Through the callback function mentioned above , Send the result back to the server .
So-called WSGI middleware At the same time API Both sides of , So you can WSGI The server and WSGI Mediation between applications : from Web From a server perspective , Middleware plays application , From an application perspective , Middleware acts as a server .“ middleware ” Components can perform the following functions :
rewrite environment variable after , According to the goal URL, Route request messages to different application objects .
Allow in one process Running multiple applications or application frameworks at the same time .
Load balancing And remoting , By means of The Internet Forward request and response messages on .
Post process the content , For example, application XSLT Style sheets
WSGI It's an agreement , The server implements WSGI standard ,application Application implementation WSGI standard , In this way, the server and application can be combined
uWSGI It's a Web The server , It has achieved WSGI agreement 、uwsgi、http Such agreement .Nginx in HttpUwsgiModule Its function is to communicate with uWSGI The server exchanges .
it is to be noted that WSGI / uwsgi / uWSGI The distinction between these three concepts .
WSGI Is a communication protocol .
uwsgi It's a line protocol, not a communication protocol , This is often used in uWSGI Data communication between server and other network servers .
and uWSGI Is to implement the uwsgi and WSGI Two kinds of agreement Web The server .
uwsgi The agreement is a uWSGI The server has its own protocol , It is used to define the type of information transmitted (type of information), every last uwsgi packet front 4byte Description of the type of information transmitted , It is associated with WSGI There are two things in comparison .