# Nginx good with many simultaneous PHP users?

**URL:** <https://www.ruby-forum.com/t/nginx-good-with-many-simultaneous-php-users/219605>\
**Category:** NGINX\
**Created:** [May 8, 2012, 7:30pm UTC](https://www.ruby-forum.com/t/nginx-good-with-many-simultaneous-php-users/219605 "2012-05-08T19:30:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [May 8, 2012, 7:30pm UTC](https://www.ruby-forum.com/t/nginx-good-with-many-simultaneous-php-users/219605/1 "2012-05-08T19:30:52Z")

</div>

Hi all,

Got the usual LAMP setup currently, trying to decide whether to swap out  
Apache and fully replace with Nginx, or to stick Nginx in front of  
Apache just to serve static content and let Apache handle the PHP  
stuff.

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.

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? (I have 5.4.1 installed).

Many thanks,  
Alex

Posted at Nginx Forum:

> **[Nginx good with many simultaneous PHP users?](https://forum.nginx.org/read.php?2,226185,226185#msg-226185)**
>
> Hi all, Got the usual LAMP setup currently, trying to decide whether to swap out Apache and fully replace with Nginx, or to stick Nginx in front of Apache just to serve static content and let Apache handle the PHP stuff. Is Nginx+PHP good with...

---

<div class="post-metadata">

**Author:** ![alexkerr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc79bd/32.png) [@alexkerr](https://www.ruby-forum.com/u/alexkerr)\
**Post date:** [May 8, 2012, 11:36pm UTC](https://www.ruby-forum.com/t/nginx-good-with-many-simultaneous-php-users/219605/2 "2012-05-08T23:36:48Z")

</div>

> 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
