Nginx on Windows PHP fastcgi read timeouts

So this is going to be a bit of a long post but if i have encounterd
this
issue no doubt someone else will.

Basically i keep getting read time outs or my web pages take a very long
time to load.

My server is Windows 2008 R2 64bit.
Everything runs under either System or Root
1GBPS Connection server is from OVH.co.uk |
http://www.ovh.co.uk/dedicated_servers/infra/2014-EG-32.xml

My web application is Joomla 2.5.x
External components i use are com_hwdmediashare and com_kunena.
And i use MySQLi instead of MySQL.

My PHP build is PHP 5.4 (5.4.29) x86 NTS (32bit)
No caching extensions enabled

My MySQL server is 5.6.19 (64bit)
MySQL tables i use are all InnoDB

Sever is Nginx from http://nginx-win.ecsds.eu/ But i was able to
replicate
this error with the official builds too
nginx: download

What runs on the server ?
Just Nginx port 80, PHP port 9000-9100, MySQL port 3306.

How i know it is not a MySQL or PHP issue ?
With mysql i enabled slow query logging and i have no queries that are
longer than 2 seconds.
With PHP i added into Joomla a time to load page feature it shows me the
time to create page was always a second or less. “Time to create page:
0.109
seconds”

Now very often pages take 30 seconds or more to load but yet if i am to
access a page through nginx that is not php. (Html or any other static
content) it loads instantly all the time.

So how do i serve PHP traffic through Nginx ?
I use FastCGI. (This is what i believe is the culprit.)

Bellow i will link to my Configs and hope someone can help me understand
why
i am having such a headache and constant read timeouts and downtime of
my
site(s). Perhaps i have reached my limit with windows and should be
using
linux :frowning:

PHP.ini Config :
http://pastebin.com/54A3PDwU

MySQL Config : (This was generated by the MySQL installer and the MySQL
server runs fine)
http://pastebin.com/DKiWjNqh

Nginx Config :
http://pastebin.com/J3tqnGpJ

Bat Files to run PHP under FastCGI in windows on Nginx (Thanks to
itpp2012
for these | Re: How to disable output buffering with PHP and nginx)
multi_run.cmd :
multi_run.cmd - Pastebin.com

runcgi.cmd :

Bare in mind this is a Windows setup not Linux.

Posted at Nginx Forum:

I’m not sure how you’d diagnose this on windows, I had a similar issue
with php-fpm under linux as it was running out of “handlers”. Could it
be that all 20 of your fastcgi processes are in use and nginx is waiting
for one to become available?

As a side note, why windows? I’m curious why you’d be running this setup
on windows when it would normally be seen running on linux.

Steve.

Not a bad suggestion steve to test it i just changed my php mark to 100
processes will wait and see if i still get read time outs.

And to answer your other question about why i do not use linux.

I don’t use linux because i am not very good with linux machines my
understanding and trying to get to grips with setting one up and putty
is
very hard for me.

And i suppose i have the kind of attitude of if linux can do it, Windows
can
do it.

Posted at Nginx Forum:

I am still having the same issue read time outs. If every request made
to
the server circles the upstream then it has to be the upstream that is
the
issue not php. PHP loads are fine no crashes no errors.

Posted at Nginx Forum:

On 18/06/2014 00:39, c0nw0nk wrote:

I am still having the same issue read time outs. If every request made to
the server circles the upstream then it has to be the upstream that is the
issue not php. PHP loads are fine no crashes no errors.

What’s in the logs?

Steve.

What logs you want me to paste PHP or Nginx ?

Posted at Nginx Forum:

Could traffic surges do that too ? Such as after i leave php running for
a
while it seems to not take as long to load ?

Posted at Nginx Forum:

PHP_FCGI_MAX_REQUESTS=0, try the recommended value of 10000.

Posted at Nginx Forum:

Lets see some logging.

Posted at Nginx Forum:

c0nw0nk Wrote:

error_log logs/error.log crit;

Is my current setting should i change it to debug ?

No option is required to get error messages about backend issues.

Remove that first server {} block with the return 200, for fcgi try
this;

        fastcgi_pass  web_rack;
        fastcgi_index index.php;
        include fastcgi_params;
        keepalive_timeout  600;
        keepalive_requests 500;
        proxy_http_version 1.1;
        proxy_ignore_client_abort on;
        fastcgi_param SCRIPT_FILENAME

$document_root$fastcgi_script_name;
fastcgi_keep_conn on;
expires 10s;

When you experience a slow page what are the php-cgi processes / mysql
doing
? use processexplorer to find out.

Posted at Nginx Forum:

Looking at it PHP, MySQL and Nginx have no changes in CPU although PHP
did
spike in I/O usage.

And i disabled caching in Joomla and sometimes i came across this.
PHP Fatal error: Maximum execution time of 30 seconds exceeded in
C:\server\websites\ps\public_www\libraries\loader.php on line 183

Do you recon that could be my bottle neck ?

Posted at Nginx Forum:

Even with PHP_FCGI_MAX_REQUESTS=10000 i still get it what log setting
would
you like nginx set to ?

Because mysql has no outputs in the slow query log that take more than 2
seconds and PHP has no error outputs or crashes in my syslog.

error_log logs/error.log crit;

Is my current setting should i change it to debug ?

Posted at Nginx Forum:

To change the Maximum execution time, in your php.ini change
max_execution_time 30 to 120. The maximum execution time is how low a
php script may run for in seconds.


Kurt C.
http://www.getwnmp.org

I meant change max_execution_time = 30 to max_execution_time = 120


Kurt C.
http://www.getwnmp.org

Doing further testing i have discoverd something disturbing.

I can execute a page upon the website, the page never loads. Then when i
go
to load other pages they all give of a error.

Fatal error: Maximum execution time of 30 seconds exceeded in
C:\server\websites\ps\public_www\libraries\loader.php on line 183

So the one page that does not load triggers a knock on effect to all
other
pages it’s like playing domino’s

Posted at Nginx Forum:

Upon the change it gets worse now i do not even get a error the browser
just
time’s out. I have no idea if it is a Joomla issue or if it is actualy
something with PHP on windows. I get the feeling it is a bit of both.

Posted at Nginx Forum:

c0nw0nk Wrote:

Upon the change it gets worse now i do not even get a error the
browser just time’s out. I have no idea if it is a Joomla issue or if
it is actualy something with PHP on windows. I get the feeling it is a
bit of both.

Then you first need to figure out why joomla needs so much time, maybe
it is
waiting for mysql without getting anywhere.
Can be anything, invalid request ending in a loop, too many nested /
unions
queries timing out mysql…

Posted at Nginx Forum:

Hello!

On Wed, Jun 18, 2014 at 09:21:55AM -0400, c0nw0nk wrote:

Even with PHP_FCGI_MAX_REQUESTS=10000 i still get it what log setting would
you like nginx set to ?

Because mysql has no outputs in the slow query log that take more than 2
seconds and PHP has no error outputs or crashes in my syslog.

error_log logs/error.log crit;

Is my current setting should i change it to debug ?

It’s very bad idea to run production systems with error_log level
set to “crit”. It basically forbids any logging of non-fatal
errors, and backend timeouts are certainly non-fatal.

To see log messages about backend issues you should set logging
level to at least “error” (as it is by default).


Maxim D.
http://nginx.org/

Yep it is a PHP application error.

My Nginx log now outputs this. I doing more digging to see why it is
acting
up.

2014/06/18 23:20:49 [error] 3792#7764: *22709 upstream timed out (10060:
A
connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond) while reading response header from
upstream, client: 10.71.9.108, server: domain.com, request: “GET
/media-gallery/9329-video-2014-06-06-08-25-27.html HTTP/1.1”, upstream:
“fastcgi://127.0.0.1:9018”, host: “www.domain.com”, referrer:
http://www.domain.com/media-gallery.html?start=60

Posted at Nginx Forum:

I found the cause on ever page i noticed it had Google Map’s/Location
running the person who wrote the Location addon in the component on
Joomla
for some reason thought it was good coding to wait for a link load. So
the
reason it time’d out is because it is connecting to a google maps link
that
never ever loads or finishes loading. (Invalid link.)

Posted at Nginx Forum: