[RndTbl] Apache MPM choice for PHP + HTTP2

Adam Thompson athompso at athompso.net
Mon Jul 24 06:23:19 CDT 2017


Correct, nginx is no faster than Apache for executing PHP code.  (Nginx requires the use of php-fpm.)
The main advantage of php-fpm in my experience is the _lack_ of memory exhaustion that can occur trivially with mod_php.
Every single site running mod_php that I manage has been DoS'd - likely by accident - this year.  Switching to php-fpm solves the problem.  And it gives me stats about PHP execution that Apache can't.

It also gives you back the ability to control what userid the php code executes as.

The performance hit of going over an IPC channel is offset by not needing to fork and initialize a massive interpreter for every hit.
For trivial or synthetic benchmarks, I expect you could still make mod_php look faster, but for most apps today (e.g. WordPress, Drupal, etc.) php-fpm wins hands down. 
*Your* code is probably lean enough that you won't see any performance difference at all.

Also, you can run multiple versions of PHP on the same webserver, which you can't do with mod_php.

Aside:

IMHO, nginx's main advantage over Apache isn't speed, it's that the config file is much more human-readable, MUCH shorter, and positively declares everything instead of relying on imputed or inferred directives elsewhere that interact and combine.

Typical Apache configs are >1k lines (yeah, that includes comments, but that's still part of the problem).  Translating that to nginx typically results in a config file that's <100 lines.

It's almost exactly like comparing sendmail to, say, postfix: both get the job done, but with wildly different approaches.

-Adam

On July 24, 2017 5:11:24 AM CDT, Trevor Cordes <trevor at tecnopolis.ca> wrote:
>Trying to get HTTP2 support working in Apache, easy enough.  Except
>when I 
>restart apache it complains that mod_http2 is not compatible with mpm 
>prefork and turns http2 off.
>
>OK, I go back to figure out why I'm running prefork.  Turns out that
>still 
>seems to be the easiest/best way to work with PHP via mod_php.  Some 
>research reveals talks from 5+ years ago that say that not every PHP 
>module that may be compiled in (in a normal distro) is thread safe, so
>all 
>of the threaded mpm's are out of the question.  Doh.
>
>But some people (but not anyone official!) say that the above is dated
>and 
>PHP should be fine with threaded mpm's.  This isn't the type of thing I
>
>want to throw out there and see if users can deadlock my apache!  Who
>to 
>believe...
>
>So, what are MUUGers who use apache and PHP using as their mpm?  Anyone
>
>successfully using a threaded mpm in this setup on complicated PHP
>sites 
>without problems?
>
>It looks like the only other option (short of running 2 servers + rev 
>proxy) is php-fpm, which I'm not familiar with but appears to run PHP 
>outside of apache in its own daemon and talk directly with apache via 
>fastcgi or similar.  From what I read it shouldn't kill performance but
>I 
>thought the whole point of mod_php was to put php inside apache for
>speed.
>
>And, no, I'm not interested in moving to nginx at this time (and from 
>benchmarks I saw it's no faster for PHP anyhow).  :-)
>
>Thanks!
>_______________________________________________
>Roundtable mailing list
>Roundtable at muug.ca
>https://muug.ca/mailman/listinfo/roundtable

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://muug.ca/pipermail/roundtable/attachments/20170724/cc184a1a/attachment.html>


More information about the Roundtable mailing list