Standalone Python web server and/or nginx

一笑奈何 提交于 2019-12-09 20:16:18

问题


So I've done some reading about Python web frameworks (or servers?), mostly Tornado and Bottle but also FAPWS3, and there are still some grey areas.

First, these three web frameworks are all said to be fast, yet they all include a web server written in Python (except FAPWS3) which should be put behind nginx/Apache. Isn't this reducing the performance? I mean, we know that Python is much slower than C, why not only use nginx, or at worst, only the included Python web server?


回答1:


First of, Tornado and FAPWS3 are web servers, while Bottle is a web framework. Those belong to completely different categories.

Web frameworks are usually run as a WSGI server behind a HTTP ("web") proxy. The HTTP server included in most frameworks is only there for fast development and deployment and easy deployment on sites where high efficiency doesn't matter.

The idea is basically that the HTTP Server (Apache/Lighttpd/Nginx/Tornado/FAPWS3 etc) is very good at understanding HTTP and serving static files from the disk. The dynamic content on the other hand is generated by a Python server using a web framework like Bottle/Flask/web.py/Pylons/etc. The document produced by the web framework is then sent back to the HTTP server over WSGI, put in a HTTP Response and sent to the client.



来源:https://stackoverflow.com/questions/8107986/standalone-python-web-server-and-or-nginx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!