Welcome! Log In Create A New Profile

Advanced

Curious problem with PHP

June 28, 2014 03:40PM
Hi all,

I have been investigating a performance problem with my
nginx/init-fastcgi/PHP set up and I'm not having much success. All ideas
gratefully received.

It appears as if the PHP worker processes return their reply (in 100ms
or so), and then hang about for 500-700ms before being able to handle
the next message. This results in worker starvation under remarkably low
loads.

The application is a chat room. I am using the Nginx HTTP push module.
POSTed messages are passed to PHP, which uses its CURL module to write
to the /publish page. PHP also talks to MySQL for data storage.
Javascript fetches from the /subscribe address, updates the screen and
requests again. GETs from /subscribe do not involve PHP.

I know the delay is after the reply, because Firebug shows the response
time is 100 to 200ms - as expected. Ping times are 100ms plus).

With 5 PHP worker processes and three people paste/sending as fast as
they can, it is very easy to overload the system. (I can nearly do it
on my own). Each browser stores the POSTs waiting for the previous
reply thus each browser can only have one message in PHP at a time. Thus
there cannot be more than three messages in the PHP system at once. So
how can 5 workers be overloaded?

I have stopped and counted 5 of my own messages coming through over the
next 7-8 seconds. It appears from comments made on the phone, that all
messages arrive together - just late. No messages are dropped.

So it appears that worker starvation is happening - but not long
response times. Server load is also slight (machine load is pushed up
from 0.3% to 2% out of 400% - 4CPUs).

Conclusion: the worker processes are hanging about after sending their
reply for some considerable time (guess 500-700ms) before they can
handle a new message.

In an effort to identify what might cause the PHP worker process to hang
about I have:
released the session as early as possible - no change.
switched the MySQL processing from a transaction to auto-commit -
this made things slightly worse.
doubled the VPS memory - this had minimal effect but removes the
possibility of swapping
attempted to use keep-alive between nginx and the fastcgi process
(and failed. Gave up as this will probably going to make things worse -
no keep alive is the default).

Using nginx 1.4.4 , PHP 5.3.10

Has anyone got an idea as what might be happening? I'm stumped.

Thanks

Ian


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Curious problem with PHP

hobson42 June 28, 2014 03:40PM

Re: Curious problem with PHP

GreenGecko June 29, 2014 02:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 232
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready