PHP FastCGI User Interface? (Faster?)

How do you create your own FastCGI interface in PHP?

I would like to do something similar to what they do in Perl , but in PHP. Is it possible? Would it be faster?

(That is, I would like to be able to load the web application infrastructure once in memory, and then just use the FastCGI method that I provide for each request. Therefore, there is no more general pre-loading of the PHP interpreter that happens in PHP FastCGI configuration by by default.)

Hooray!

(Edit: aren't Mongrel and RoR doing this too?)

Ok, now I made a freakin 'scheme:

alt text

+2
source share
3 answers

I might be wrong (it's late), but aren't you trying to do some form of caching? Despite this, the FastCGI interface looks pretty clear. Thus, you should do whatever you want quite easily.

+1
source

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

0
source

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

After which you guessed it, you ran the PHP script, getting the fast CGI as a standalone program, executing the loop and accepting the requests. In which you use PHP as a "permanent virtual machine" (could not find a better term) that communicates via fastCGI.

I agree that reloading several of your libs / etc dependencies is very easy to overcome performance. However, this is perhaps an intentional design, in simplifying the PHP development cycle. Think of global variables as a mess that inexperienced users could do in a persistent environment. Throw in that most fastCGI settings initialize multiple copies / streams according to the load. This is a small can of worms. Starting a new new slide for each request simplifies it.

However, to be honest ... if you are concerned with performance, you can also consider fastCGI C ++ / node.js as alternatives .... Having developed for JavaScript / PHP / C ++, your idea is definitely possible ... However it really comes down to cost savings ... Is it worth the effort ?, etc.

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

0
source

All Articles