fiat wrote:
as only once instance will run, rather than an instance per apache process, at least, that is my understanding.
If you'd have one instance of PHP, you could handle one PHP request at a time, serializing your server's performance down no nothing.
Facts:
1. wth mod_prefork+mod_php there's a separate large Apache process WITH integral php parser launched for every single http connection, no matter if it's for a php script or a simple image file. That's a huge hog, and you plainly have to cut MaxClients down to a number that'll accomodate all these processes in memory.
2. With fastcgi, you "detach" PHP from Apache. There's a "manager" process, that spawns $PHP_FCGI_CHILDREN sub-handlers, so it can handle that much parallel scripts. Your apache (or any other webserver) talks to it, but only if it actually needs to execute a php script - "plain" files are served by the webserver directly.
3. If you want to use fastcgi and PHP in Apache, you need to use mod_fastcgi - mod_fcgid doesn't pipeline requests, and assumes "one subprocess = one script at a time". The whole PHP tree IS one subprocess to Apache, as you spawn only the "manager". So, mod_fcgid thinks you can execute only one PHP parser at a time.
4. If you're moving to fastcgi, there's nothing (except other non-threadsafe apapche modules you may have, that is) to hold you onto prefork. You can switch to mpm-worker, set a nice number or threads, and enjoy your fast, memory-efficient, Apache setup.
</Facts>
I have an mpm-worker setup that has 50-250 threads active (split 25 per process; probably could go for 50 per process, but don't see any need), and 25 php slaves. That means I can handle up to 250 parallel connections, 25 of which can be executing a php script, and rest pulling html files and/or images - otherwise, request is queued until a thread and/or a parser is free. It all fits in about 200MB of RAM, and that's including the 64MB shared-memory APC cache.
This thing serves about 200k hits per day without a hitch, and with about 18% CPU load in the rush hours.