自定义 PHP FastCGI 接口? (快点?)

发布于 2024-07-23 00:08:13 字数 497 浏览 3 评论 0原文

如何在 PHP 中构建自己的 FastCGI 界面?

我想做一些类似于 他们正在做的事情在 Perl 中,但在 PHP 中。 有可能吗? 会更快吗?

(也就是说,我希望能够将 Web 应用程序框架一次加载到内存中,然后让 FastCGI 调用我为每个请求提供的方法。所以不是更通用的预加载PHP 解释器发生在“默认”PHP FastCGI 设置中。)

干杯!

编辑:Mongrel 和 RoR 不也是这么做的吗?)

好吧,我现在已经制作了一个奇怪的图表:)

替代文字

How do you build your own FastCGI interface in PHP?

I'd like to do something similar to what they're doing in Perl, but in PHP. Is it even possible? Would it be faster?

(That is, I'd like to be able to load a web app framework once into memory, and then just have FastCGI call a method I provide for every request. So not the more generic preloading of the PHP-interpreter that is happening in the "default" PHP FastCGI setup.)

cheers!

(Edit: Isn't Mongrel and RoR doing this as well?)

Ok I've made a freakin' diagram now :)

alt text

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

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

发布评论

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

评论(3

心意如水 2024-07-30 00:08:13

我可能错了(已经晚了),但你不是只是想进行某种形式的缓存吗? 无论如何,FastCGI 接口似乎定义得相当好。 所以,应该可以相当容易地做任何你想做的事情。

I may be mistaken (it's late) but aren't you just trying to do some form of caching? Regardless, the FastCGI interface seems to be fairly well defined. So, it should be possible to do whatever you want, fairly easily.

美胚控场 2024-07-30 00:08:13

如果您确实决定使用 PHP,理论上您可以 创建c中的php模块,并构成c中的fastCGI的桥梁。

之后我猜测,您将运行一个 PHP 脚本,将 fastCGI 作为独立程序访问,运行循环并接受请求。 其中您使用 PHP 作为“持久虚拟机”(找不到更好的术语),通过 fastCGI 进行通信。

我确实同意,重新加载几个依赖库/等是很容易被忽视的性能消耗。 不过,这也许是有意设计的,旨在简化 PHP 开发周期。 想想没有经验的用户在持久环境中会造成的全局变量混乱。 事实上,大多数fastCGI设置,都会根据负载初始化多个副本/线程。 它是一小罐蠕虫。 为每个请求开始一个空白的新石板可以简化它。

然而,老实说......如果你关心性能,你不妨考虑 fastCGI C++ / node.js,作为替代方案......已经为 JavaScript/PHP/C++ 开发,你的想法绝对是可能的......但是它真正归结为成本效益...值得付出努力吗?等等。

PS:您也可以考虑通过 hip-hop 编译您的 PHP 网站。

If you are really determined for it to be in PHP, you could in theory, create a php module in c, and form the bridge for fastCGI in c.

After which im guessing, you would run a PHP script accessing fastCGI as a standalone program, running a loop and accepting requests. In which your using PHP as a "persistent virtual machine" (could not find a better term), that communicates via fastCGI.

I do agree that the reloading of several of your dependency libaries / etc, is a very easily over-sighted performance drain. However, it maybe intentional design, in simplifying the PHP development cycle. Think of the global variable mess inexperienced users would make, in a persistent environment. Toss in the fact that most fastCGI setup, will initialize multiple copies / threads according to the load. Its a small can of worms. Starting a blank new slate for each request simplifies it.

However, honestly... if your that concern in performance, you might as well consider fastCGI C++ / node.js, as alternatives.... Having developed for JavaScript/PHP/C++, your idea is definitely possible... However it really boils down to cost-benefit... Is it worth the effort?, etc.

PS : You can also consider compiling your PHP sites via hip-hop.

在风中等你 2024-07-30 00:08:13

对于 PHP,您可以在 PHP 中实现此操作,您可以在 C 中为 cgi-sapi 实现此操作,但是您可能想使用 APC 代替。

You can not do it in PHP for PHP, you can do it in C for cgi-sapi but you probably want to use APC instead.

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