Pros and Cons of mod_php vs. suexec+fcgid vs. php-fpm and Apache MPM

New thread for a discussion on the pros and cons of using mod_php vs. suexec+fcgid vs. php-fpm

Discussion began here:
http://virtualmin.com/node/16963

From this page, php-fpm seems like a popularly used setup: http://blog.kmp.or.at/2013/06/apache-2-2-on-debian-wheezy-w-php-fpm-fastcgi-apc-and-a-kind-of-suexec/

http://serverfault.com/questions/45042/which-to-install-apache-worker-or-prefork-what-are-the-dis-advantages-of-eac

The classic solution to running unsafe extensions while serving large numbers (>100) of concurrent connections is to run PHP on fastCGI (mod_fcgid, a native apache module) and proxy dynamic requests to that from an apache instance that runs the Worker MPM.

This would enable you to scale from a few hundred up to >1000 concurrent connections with a modest amount of memory (4~8GB) when serving a mix of static and dynamic content.

Of course, you should also investigate front-end caching solutions as part of your overall deployment (memcached, varnish).

Alternatively, upgrade to apache 2.4 and its native event MPM, which handles concurrency in a much improved fashion (threads are fired off upon connection, not waiting to be polled.)

http://coolpandaca.wordpress.com/2012/03/20/apache-mpm-worker-prefork-mod_php-mod_fcgid-mod_fastcgi-php-fpm-and-nginx/

(Good overview)

Which setup gives the most security, between virtual servers, and virtual server vs. system ?

Most efficient use of memory, for apache and PHP?

Most efficient use of cached, pre-compiled PHP opcodes shared between virtual servers running same or similar PHP apps ?

Best ability to handle high loads efficiently ?

In the thread: http://www.virtualmin.com/node/22660
It is said: “Unfortunately, PHP-FPM isn’t one of the supported PHP Execution Modes.”

Does this mean we can’t use Virtualmin with Apache + PHP-FPM at all?

Currently it seems you can add a custom user script to enable/maintain Apache + PHP-FPM with Virtualmin, but it’s officially unsupported. User janeksikora has created a script to do this with nginx + PHP-FPM…

“I’ve managed to do php-fpm&nginx with a 100 line script that is executing after creating/destroying vservers (it creates php-fpm pool for each host) and modyfing source of virtualmin-nginx module (so it uses sockets – easier [sockets are like $user.socket] and faster [than TCP]). Wasn’t so hard…”