Wsgi&asgi

Source: Internet
Author: User

    • What isWSGI
    • What isASGI
    • WSGIAnd ASGI What's the difference?
What is WSGI

First of all CGI , (Universal Gateway Interface, Common Gateway interface/cgi), a program that defines how clients communicate with the Web server. For example, under normal circumstances, the client sends a request, according to the HTTP Protocol Web server to resolve the request content, after the calculation, and then add us to the contents of the content, such as the server returned a HTML page, and based on HTTP the protocol to build the response format of the returned content. TCPthese, which involve connections, HTTP raw requests, and corresponding formats, are done by a single software, and the above work requires a program to complete, and this program is CGI .

Then what is it? WSGI As explained on the wiki, theWeb Server Gateway Interface (Python Webserver, Gateway Interface,wsgi) is Python a simple and common interface between a Web server and a Web application or framework defined for the language. Semantically understood, seemingly WSGI Python to solve the problem of communication between the Web server side and the client , and WSGI is based on existing CGI standards and design, is also a program (or Web Component Interface specification?). )。

The Wsgi area is divided into two parts: one is "server" or "gateway" and the other is "application" or "Application Framework".
The so-called WSGI middleware simultaneously implements API the two sides, namely WSGI between the server and the WSGI application mediate function: from WSGI the server angle, the middleware plays the application, but from the application angle, the middleware plays the server. Middleware has the features:

    • After overriding the environment variable, the request message is routed to a different application object based on the destination URL.
    • Allows multiple applications or application frameworks to run concurrently in one process
    • Load balancing and remoting, by forwarding requests and corresponding messages over the network.
    • Perform post-processing of content, such as applying a XSLT style sheet. (above from wiki)

Read so much, summed up, in fact, can be said to be WSGI based on Python the CGI standard to do some expansion.

What is Asgi

The Asynchronous Gateway protocol interface, a standard interface between network protocol services and Python applications, can handle a wide variety of common protocol types, including HTTP , HTTP2 and WebSocket .
However, the current common use WSGI is mainly for the HTTP style of the request response model to do the design, and more and more non-compliance with this model of the protocol gradually become Web one of the criteria, for example WebSocket .
ASGITry to maintain an abstraction that allows data to be sent and accepted at any time, by any application process, with a simple application interface. It also describes a new, compatible HTTP request response and a WebSocket sequence format for the data frame. Allows these protocols to be transmitted over the network or locally socket , and to allow different protocols to be assigned to different processes.

What's the difference between Wsgi and Asgi?

Above, WSGI is based on the HTTP protocol model, not supported WebSocket , and ASGI the birth is to solve the Python common WSGI does not support the current Web development of some new protocol standards. At the same time, ASGI for the WSGI original mode of support and WebSocket extension, that ASGI is, WSGI the extension.




Reprinted from: https://www.jianshu.com/p/65807220b44a

Wsgi&asgi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.