python scgi 和 wsgi 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/257481/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 19:45:06  来源:igfitidea点击:

What's the difference between scgi and wsgi?

pythonwsgiscgi

提问by daniels

What's the difference between these two? Which is better/faster/reliable?

这两者有什么区别?哪个更好/更快/可靠?

回答by bobince

SCGI is a language-neutral means of connecting a front-end web server and a web application. WSGI is a Python-specific interface standard for web applications.

SCGI 是一种连接前端 Web 服务器和 Web 应用程序的语言中立方式。WSGI 是用于 Web 应用程序的 Python 特定接口标准。

Though they both have roots in CGI, they're rather different in scope and you could indeed quite reasonably use both at once, for example having a mod_scgi on the webserver talk to a WSGI app run as an SCGI server. There are multiple library implementations that will run WSGI applications as SCGI servers for you (eg. wsgitools, cherrypy).

尽管它们都起源于 CGI,但它们的范围却大不相同,您确实可以非常合理地同时使用它们,例如,在 Web 服务器上使用 mod_scgi 与作为 SCGI 服务器运行的 WSGI 应用程序进行通信。有多种库实现可以将 WSGI 应用程序作为 SCGI 服务器运行(例如 wsgitools、cherrypy)。

They are both 'reliable', in as much as you can consider a specification reliable as opposed to a particular implementation. These days you would probably write your application as a WSGI callable, and consider the question of deployment separately.

它们都是“可靠的”,与特定实现相反,您可以认为规范是可靠的。现在,您可能会将您的应用程序编写为 WSGI 可调用对象,并单独考虑部署问题。

Maybe an Apache+mod_wsgi (embedded) interface might be a bitfaster than an Apache+mod_scgi+(SCGI wrapper lib), but in all likelihood it's not going to be hugelydifferent. More valuable is the ability to run the application on a variety of servers, platforms and connection standards.

也许一个Apache + mod_wsgi的(嵌入式)接口可能是一个有点比一个Apache + mod_scgi +(SCGI包装LIB)快,但在所有的可能性,它不会是巨大的不同。更有价值的是能够在各种服务器、平台和连接标准上运行应用程序。

回答by daniels

SCGI (like FastCGI) is a (serialized) protocol suitable for inter-process communication between a web-server and a web-application.

SCGI(如 FastCGI)是一种(序列化)协议,适用于 Web 服务器和 Web 应用程序之间的进程间通信。

WSGI is a Python API, connecting two (or more) Python WSGI-compatible modules inside the same process (Python interpreter). One module represents the web-server (being either a Python in-process web-server implementation or a gateway to a web-server in another process via e.g. SCGI). The other module is or represents the web application. Additionally, zero or more modules between theses two modules, may serve as WSGI "middleware" modules, doing things like session/cookie management, content caching, authentication, etc. The WSGI API uses Python language features like iteration/generators and passing of callable objects between the cooperating WSGI-compatible modules.

WSGI 是一个 Python API,在同一进程(Python 解释器)内连接两个(或更多)Python WSGI 兼容模块。一个模块代表网络服务器(要么是 Python 进程内网络服务器实现,要么是通过 SCGI 等其他进程中网络服务器的网关)。另一个模块是或代表 Web 应用程序。此外,这两个模块之间的零个或多个模块可以作为 WSGI“中间件”模块,执行会话/cookie 管理、内容缓存、身份验证等操作。 WSGI API 使用 Python 语言功能,如迭代/生成器和可调用的传递协作的 WSGI 兼容模块之间的对象。

回答by Ali Afshar

They are both specifications for plugging a web application into a web server. One glaring difference is that WSGI comes from the Python world, and I believe there are no non-python implementations.

它们都是将 Web 应用程序插入 Web 服务器的规范。一个明显的区别是 WSGI 来自 Python 世界,我相信没有非 Python 实现。

Specifications are generally not comparable based on better/faster/reliable.

规格通常无法基于更好/更快/可靠进行比较。

Only their implementations are comparable, and I am sure you will find good implementations of both specifications.

只有它们的实现具有可比性,我相信您会找到两种规范的良好实现。

Perhaps readand read.

也许阅读阅读