WSGI、CGI、FastCGI 和 mod_python 在 Python 方面的区别和用途?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3937224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Differences and uses between WSGI, CGI, FastCGI, and mod_python in regards to Python?
提问by Parker
I'm just wondering what the differences and advantages are for the different CGI's out there. Which one would be best for python scripts, and how would I tell the script what to use?
我只是想知道不同 CGI 的区别和优势是什么。哪一个最适合 python 脚本,我如何告诉脚本使用什么?
采纳答案by pyfunc
A part answer to your question, including scgi.
您问题的部分答案,包括scgi。
- What's the difference between scgi and wsgi?
- Is there a speed difference between WSGI and FCGI?
- How Python web frameworks, WSGI and CGI fit together
CGI vs FCGI
CGI 与 FCGI
Lazy and not writing it on my own. From the wikipedia: http://en.wikipedia.org/wiki/FastCGI
懒惰,不是自己写的。来自维基百科:http: //en.wikipedia.org/wiki/FastCGI
Instead of creating a new process for each request, FastCGI uses persistent processes to handle such requests. Multiple processes can configured, increasing stability and scalability. Each individual FastCGI process can handle many requests over its lifetime, thereby avoiding the overhead of per-request process creation and termination
FastCGI 不是为每个请求创建一个新进程,而是使用持久进程来处理此类请求。可以配置多个进程,增加稳定性和可扩展性。每个单独的 FastCGI 进程可以在其生命周期内处理许多请求,从而避免每个请求进程创建和终止的开销
回答by Richard Boardman
There's also a good background reader on CGI, WSGI and other options, in the form of an official python HOWTO: http://docs.python.org/2/howto/webservers.html
还有一个很好的关于 CGI、WSGI 和其他选项的背景阅读器,以官方 python HOWTO 的形式:http: //docs.python.org/2/howto/webservers.html
回答by Cees Timmerman
In a project like Django, you can use a WSGI (Web Server Gateway Interface) server from the Flup module.
在像Django这样的项目中,您可以使用Flup 模块中的 WSGI(Web 服务器网关接口)服务器。
A WSGI server wraps a back-end process using one or more protocols:
WSGI 服务器使用一个或多个协议包装后端进程:
- FastCGI(calling a server process)
- SCGI (Simple Common Gateway Interface- a simpler FastCGI)
- AJP (Apache JServ Protocol- a Java FastCGI)
- mod_python(runs pre-loaded code per request - uses lots of RAM)
- CGI (Common Gateway Interface, starts a process per request - slow)
- FastCGI(调用服务器进程)
- SCGI(简单通用网关接口- 更简单的 FastCGI)
- AJP(Apache JServ 协议- Java FastCGI)
- mod_python(每个请求运行预加载的代码 - 使用大量 RAM)
- CGI(通用网关接口,每个请求启动一个进程 - 慢)
回答by naveenKumar
- FastCGI is a kind of CGI which is long-live, which will always be running.
- With FastCGI, it'll take less time.
- Because of multi-processes, FastCGI will cost more memory than CGI.
- FastCGI 是一种长寿命的 CGI,它会一直运行。
- 使用 FastCGI,它会花费更少的时间。
- 由于多进程,FastCGI 将比 CGI 消耗更多内存。

