Why is Nginx so mature that Python has a variety of web frameworks such as web.py?

Source: Internet
Author: User

Reply content:

Nginx is the server, web.py is the Web application framework.

In short, the former encapsulates the processing of network IO, the latter is responsible for the specific application of the logic, solve the problem is not the same. Image point, a request came, Nginx first pull down the request, found to be out of the box (static file), it will directly put the ready-made static files back to the client, so fast, if the other request, After handing over to Web.py solves, web.py solves, only then generates to return the content, does not own network IO, but is handled by the Nginx.

So much good, a peace of mind to deal with the network, concurrency, by the way to meet the simple request directly KO off. Another application-focused logic.

Of course, Nginx can do more than this, and in order to develop a convenient web.py and other frameworks are built-in simple Web server.

As for tornado, it has both a Web application framework and a Web server, and this server uses a high-performance single-threaded, non-blocking asynchronous model, an exception. Nginx is a static content and front-end agent-based server, Python's various frameworks for the implementation of dynamic logic.

Common collocation is the Nginx listening client connection, directly respond to static requests (picture, CSS, JS, etc.), and then transfer the dynamic request through FastCGI (web.py) or proxy (Tornado) to the backend server for processing. Nginx itself is written in C, the code is highly efficient, supports dynamic balance, and is more stable and efficient than directly using Python to face large-scale requests.

Web.py these frameworks sometimes come with a server for development, but this server (like Simplehttpserver in the Python standard library) does not respond well to high loads and is not intended for production environments.

The real competitive relationship with Nginx is Tornado and some servers based on Twisted. These servers themselves are designed for direct connection clients and support some of the protocols not supported by Nginx reverse proxies such as WebSocket. In a sufficiently complex, modular range of projects, Nginx supports static files, Tornado supports Comet services, and then one end proxies more of the combined form of business logic. Nginx wants to do more agent and balanced load, but is not likely to perform the strong logically album. It is like a family, only power but not to do things, and then it is the role of the family.

and congregation many logically the frame such as web.py is a son running in the back, the management of various business logically album.

Why did Nginx not also do the son of things do? It's not good, because it's hard to use a program to solve all of the business, and then it becomes another language solver ... Big and complicated, not feasible. And son is not likely to do a family thing, because the business logically is important is the expansion of malleable and force.

So they split up .... Generally use the flask or Django Application Frameworkwill use the USWGI Serverdeployment, but the USWGI itself does not Direct Connect ClientDo optimization, so the general will be NGINX+USWGI, using Nginx Connection client to USWGI distribution request to improve efficiency, so that there is no USWGI Slow IOProblem, but also can do static and dynamic separation and so on various. The answer to the high ranking such as Tornado is also clear. Web server? Nginx's author is going to cry,!!!!!!. People are a good performance io things to use their own development of the server as a production?
  • Related Article

    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.