Question

I was under the impression that FastCGI allowed you to kinda load in your web app once, and then you just "provide" FastCGI with some function, like myHandleHTTPRequest($url), that would then be called whenever a request came. This way you'd get much better performance as your app is ready in memory all the time, right?

But I'm starting to understand, that this is not the case. Or am I mistaken?

It seems to me, that PHP is being loaded by FastCGI, ok, and this gives some improvement, but then my app is still being reloaded on every request.

I'd like to load my app (or read 'framework') once (and then reload say every 500 requests or so.) Can I do that?

Edit: This question has been rephrased into this one: Custom PHP FastCGI interface

Was it helpful?

Solution

Yeah, you can do that, by more or less forgetting about all of the fancy PHP integration stuff (that being what's giving you General-Purpose-PHP-Interpreter-As-FastCGI) and writing your application as a FastCGI server in and of itself.

That's kind of a whole 'nother topic, but you might want to look into how Perl apps go about it for a guide.

OTHER TIPS

What fastcgi does is to avoid spawning a php interpreter for every request (like cgi does). This saves huge amounts of processing time, as the php interpreter is kept in memory, more or less like mod_php does.

What you can do to improve performance is:

  1. Use APC, or xcache, etc, which precompiles every php file transparently, avoiding re-compilation on every request.
  2. Caching. Apc and others provide mechanisms to store variables with a lifetime that spans even between requests. This can be used to share processed data between requests, and keep application data in memory.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top