Forum: NGINX PHP-FPM Performance

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7b660a44f60a7ba9bb6e12d817f4b038?d=identicon&s=25 Mathew Davies (Guest)
on 2008-12-20 19:47
(Received via mailing list)
Hi,

I'm currently using nginx/0.7.27 + PHP 5.2.8 with the fpm patch on
Ubuntu Server 8.10 with 256 MB RAM. Nginx is serving static files very
fast at 1,500 req/s while serving a phpinfo(); page will drop right
down to 300 req/s. This performance is nothing to be sniffed at with
the current specifications of the machine, but I'm wandering if there
is any room to squeeze more performance from the php side of things.

Kind Regards,
-Mathew Davies.
5847d655e3d76df019749c1201c37dc2?d=identicon&s=25 Sergio Bruder (Guest)
on 2008-12-21 01:16
(Received via mailing list)
Em 20/12/2008, às 16:37, Mathew Davies escreveu:

> -Mathew Davies.
You are using some accelerator? PHP acelerators brings a moderate gain
of performance and a better gain in parallelism in my humble experience
(because of gains in memory allocation per process).

Sergio Devojno Bruder
bruder@haxent.com.br
7b660a44f60a7ba9bb6e12d817f4b038?d=identicon&s=25 Mathew Davies (Guest)
on 2008-12-21 01:54
(Received via mailing list)
I currently have APC installed and it's caching the pages correctly. I
did experiment with the nginx memcached module where nginx would
simply bypass the php altogther, this massively improved performance
to the sound of 1,200 req/s, but it's not easy to implement into my
current web application.

I'm quite new to nginx so I've attached my configs incase I've missed
something.

nginx.conf
http://pastie.org/private/q2eqdofkwf2fqahl4xjqpa

php-fpm.conf
http://pastie.org/private/mvitmolavbcqfwpp944xfq
3eca00a0d3f5725d81723b69621287bd?d=identicon&s=25 Marcos Neves (Guest)
on 2008-12-21 10:34
(Received via mailing list)
I think your performance is correct. On my machine phpinfo() is taking
2.8 seconds to complete, and that will result in 300 req/s
Try with this script:
http://gist.github.com/38628

What  location @dynamic does?

Marcos Neves
+55 44 3263-8132
+55 44 9918-8488



2008/12/20 Mathew Davies <thepixeldeveloper@googlemail.com>:
7b660a44f60a7ba9bb6e12d817f4b038?d=identicon&s=25 Mathew Davies (Guest)
on 2008-12-21 16:35
(Received via mailing list)
That was for when I using a memcached server to bypass PHP. The script
produces an average of 1.2ms. I guess I can get no more out of my
small VPS package so thank you for all the help Sergio and Marcos.

Ps : I'm very pleased with 300req/s. :)
3eca00a0d3f5725d81723b69621287bd?d=identicon&s=25 Marcos Neves (Guest)
on 2008-12-22 02:10
(Received via mailing list)
What  location @dynamic does?

Where´s your VPS and what´re your impressions?

Marcos Neves
+55 44 3263-8132
+55 44 9918-8488



2008/12/21 Mathew Davies <thepixeldeveloper@googlemail.com>:
56080a668b706e94fb2bbe9ee727d006?d=identicon&s=25 Reinis Rozitis (Guest)
on 2008-12-22 19:12
(Received via mailing list)
Just a note - dont test with <? phpinfo(); ?> do something like <? echo
'Hello world!'; ?> and test then..
Because phpinfo() is pretty bloated and intensive (in the past also even
with memory leaks).


rr

----- Original Message -----
From: "Mathew Davies" <thepixeldeveloper@googlemail.com>
To: <nginx@sysoev.ru>
Sent: Saturday, December 20, 2008 8:37 PM
Subject: PHP-FPM Performance
3eca00a0d3f5725d81723b69621287bd?d=identicon&s=25 Marcos Neves (Guest)
on 2008-12-23 01:16
(Received via mailing list)
I totally agree. What you are really trying to banchmark is the time
to php respond to nginx and nginx respond to the client.
Just it.

Marcos Neves
+55 44 3263-8132
+55 44 9918-8488



2008/12/22 Reinis Rozitis <r@roze.lv>:
7b660a44f60a7ba9bb6e12d817f4b038?d=identicon&s=25 Mathew Davies (Guest)
on 2008-12-29 16:57
(Received via mailing list)
Thanks for the comments.

Marcos. I am planning to use a VPS at Slicehost, but I have created a
virtual machine with the same specification at home to replicate it.

Reinis. That had little effect on the end result.
7b660a44f60a7ba9bb6e12d817f4b038?d=identicon&s=25 Mathew Davies (Guest)
on 2008-12-29 17:00
(Received via mailing list)
I forgot to add.

Would it be more beneficial to have NGinx pass off the PHP requests to
Apache as it runs PHP as a module?

On Mon, Dec 29, 2008 at 3:47 PM, Mathew Davies
3eca00a0d3f5725d81723b69621287bd?d=identicon&s=25 Marcos Neves (Guest)
on 2008-12-29 17:10
(Received via mailing list)
I´m not sure, cause php-fpm already keep PHP on the memory, doesn´t it?
So I think php-fpm is more optimized, cause there´s no need to parse
http again. (I think).

Marcos Neves
+55 44 3263-8132
+55 44 9918-8488



2008/12/29 Mathew Davies <thepixeldeveloper@googlemail.com>:
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 mike (Guest)
on 2008-12-29 22:32
(Received via mailing list)
Correct. Mod_php in apache has to scale with the webserver. Fastcgi
allows it to scale modularly. It can be separated into different
servers if needed.

On Dec 29, 2008, at 8:00 AM, "Marcos Neves" <marcos.neves@gmail.com>
56080a668b706e94fb2bbe9ee727d006?d=identicon&s=25 Reinis Rozitis (Guest)
on 2008-12-29 22:39
(Received via mailing list)
>I forgot to add.
>
> Would it be more beneficial to have NGinx pass off the PHP requests to
> Apache as it runs PHP as a module?

In my opinion tottaly no (although people sometimes make proxy setups to
pass the dynamic requests back to apache backend but handle the static
via
nginx - still its often because of some apaches features like php_flag
php_admin_*).

Although you can try to play arround with the apache MPM modules -
prefork
is still the common mechanism which means that for each request a new
process is forked/launched and after it finishes the child killed..
PHP childs in fastcgi mode live much longer (can be specified) and dont
consume cpu resources just on spawning also something like persistant
connections to DBs or other services work much better instead of dieing
each
time with apache.


Well initially it seems something wrong with your setup/performance
results - at first getting only 1.5k req/sec for static content is
somehow
low ..You should be able to get 15-30k and even more requests per second
(at
least with 'ab' testing one file).. Of course php is much slower but
still a
simple 'hello world' on a single box should be able to manage up to 2k
req/s
..

So either the box is kinda weak or you havent tweaked some system
settings
like max open files or tcp params.

rr
This topic is locked and can not be replied to.