了解 Rails 中的 CGI / FastCGI

发布于 2024-07-26 14:49:53 字数 198 浏览 5 评论 0原文

这更多的是为了理解Web应用程序中的请求-响应机制。 客户端向 Web 应用程序发送请求 (GET / POST)。 Web 应用程序有一个正在运行的应用程序服务器,它充当应用程序特定程序的容器。 我不明白应用程序服务器启动 FastCGI / CGI 进程时的部分。 CGI的意义何在? 服务器不是被设计来处理完整的请求处理机制吗? 请求处理的哪一部分依赖于 CGI?

This is more to understand the request-response mechanism in web apps. A client sends a request (GET / POST) to a web app. The web app has an application server running which serves as the container for the application specific programs. I don't understand the part when the app server starts a FastCGI / CGI process. What is the significance of CGI? Aren't the servers designed to handle the complete request handling mechanism? What part of the request handling relies on CGI?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

单挑你×的.吻 2024-08-02 14:49:53

我在这里问了一个类似的问题(尽管它比概念更接近实现):
HTTP 请求从 Web 服务器分派到 CGI/ FastCGI 流程

然而,这是我在此过程中学到的东西:
CGI 是一组定义 HTTP/Web 服务器应如何与外部程序通信的“标准”。 注意“标准”这个词! 虽然不是一个彻头彻尾的协议(如 HTTP、TCP 等),但它非常接近一个协议,因为大多数生成 HTML 的外部程序(Ruby、PHP、Python 等)都遵守一组标准。

您可以在这里阅读有关 CGI 的更多信息:
http://hoohoo.ncsa.illinois.edu/cgi/intro.html

这里:
http://www.w3.org/CGI/

FastCGI 是对 CGI 处理方式的改进处理 - 以一种超级简单的方式,FastCGI 进程在内存中保持加载的时间更长,以便在加载到内存中时可以处理多个请求。 显然,从那时起,这种方式的工作效率就更高了。 加载基本 CGI 环境时丢失的资源在 FastCGI 进程中从来不会经常发生,

有点偏离轨道,并且是 Rails 特有的,但这是一篇有趣的文章:
http:// /izumi.plan99.net/blog/index.php/2007/04/05/ saving-memory-in-ruby-on-rails/

I asked a similar (although it's more close to implementation then concepts) question here:
HTTP request dispatch from Web Server to a CGI/FastCGI process

However, here's what I've been able to learn on the way:
CGI is a set of "standards" that define how an HTTP/Web Server should communicate with external programs. Note the word standards! Although not an out and out protocol (like HTTP, TCP etc) but it is pretty close being one as the set of standards are complied to by most of the external programs that generate HTML (Ruby, PHP, Python etc).

You can read more about CGI here:
http://hoohoo.ncsa.illinois.edu/cgi/intro.html

and here:
http://www.w3.org/CGI/

FastCGI is an improvement on the way CGI processes are handled - put in a super simple way a FastCGI process stays loaded in the memory for a longer time so that it can process multiple requests while it's loaded in the memory. Obviously that works more efficiently since the time & resources lost in loading the basic CGI environment never does happen that frequently in FastCGI processes

A little off the track and Rails specific, but this is an interesting artice:
http://izumi.plan99.net/blog/index.php/2007/04/05/saving-memory-in-ruby-on-rails/

长亭外,古道边 2024-08-02 14:49:53

客户端(通常是浏览器)和 Web 服务器之间的通信通过 http 进行。
当 Web 服务器收到请求时,它会分析请求的要求,并返回适当的输出。 请求可以是存储在磁盘上的文件,然后服务器只返回文件的内容。 如果请求标识了一个程序(您的CGI),它将执行它并返回您的输出向客户端编程。

The communication between the client (tipically a browser) and the Web server is over http.
When the Web server receives a Request, it analyzes what the request ask for, and return the appropiate output. The request can be to a file stored on disk, then the server just returns the content of the file. If the request identifies a program (your CGI) it will execute it and return the output of your programm to the Client.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文