Nginx good with many simultaneous PHP users?

Reinis Rozitis r at roze.lv
Tue May 8 21:36:25 UTC 2012


> Is Nginx+PHP good with potentially many (hundreds or thousands) or 
> simultaneous users accessing a lightweight PHP script (does a couple of
> MySQL reads and maybe a write or two)? (users all using the site 
> simultaneously but not necessarily that many actually accessing the PHP
> script simultaneously). I'm seeing conflicting answers to this question 
> from online research.

In short yes, but to be specific - it depends.

Based on your current setup and the nature of website (distribution between 
dynamic and static content) the improvements may be (very) noticeable 
especially if you're still using the old prefers in Apache rather any of the 
threading MPMs.

The major benefits in my opinion/experience is having more control over the 
resources - first of all you spend way less for the static content (Apache 
more or less loads the php module/engine for everything).
The fpm manager can also identify/trace (log) slow running script and/or 
even forcibly kill them if they exceed the given thresholds (it is pretty 
useful if all your code isn't written by yourself) .
Your are also not stuck with figuring out what MaxClients / MinSpareThreads 
etc set to satisfy all clients/requests (incoming bursts etc) the fpm has 
adaptive spawning and also ability to notify if the configuration settings 
are too low.

While it may only still be true with the prefork case (I haven't tested the 
latest releases/threading models since went away from Apache 5 years ago) 
the permanent fastcgi php processes give you the advantage of using 
persistent connections to your backends (mysql, memcache etc) that way 
speeding up the web application.



> Also, re: PHP specifically, looks like php-fpm has been absorbed into 
> latest PHP 5.4.x so I don't need to explicitly install php-fpm - is that 
> correct?

FPM has been merged into php since 5.3.3 (so quite a while ago).


Anyways if you allready have nginx in your infrastucture then plugging in 
php for it shouldn't take too much effort. Test it for yourself.


rr 



More information about the nginx mailing list