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.
source share