douwei8672
2009-06-01 15:01
浏览 34
已采纳

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

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

图片转代码服务由CSDN问答提供 功能建议

如何在PHP中构建自己的FastCGI接口?

我' 我喜欢做类似于他们在Perl中执行的 ,但在PHP中。 它甚至可能吗? 它会更快吗?

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

欢呼! \ n

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

好的我现在做了一个怪胎图: )

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • douhuan1497 2009-06-01 15:04
    已采纳

    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.

    已采纳该答案
    评论
    解决 无用
    打赏 举报
  • douxiuar885064 2009-07-10 04:06

    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.

    评论
    解决 无用
    打赏 举报
  • douhui1957 2012-07-12 05:31

    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.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题