Webserver hangs connecting to SQL2005.

Occasionally our website seems to 'hang'. No pages get returned to the browser.
webserver: Win2k3 IIS6 Zend 2.5.2
Db server: MS MSQL 2k5 on another box
When this happens the Application Log in event viewer on the webserver has a whole series of errors like this:
"Can not connect() to C:\Program Files\Zend\Core\bin\php-cgi.exe - [10060]"

Sometimes the error number is 1460:

"Can not read response from C:\Program Files\Zend\Core\bin\php-cgi.exe - [1460]"

These messages appear several times a second in the log.

Restarting the Web Service fixes the problem for several hours. Then it occurs again.

Any ideas where my problem lies?

Many thanks for any help....
Who is Participating?
cj_1969Connect With a Mentor Commented:
If you want to test this try a test server and configure it for 1 instance ... run a load test against it with a number of different requests for information and see if you can get 1 instance to hang or produce the errors.  If you can then you know it is something code specific within a single instance.  
If this does not work then increase the number of threads/processes to 2.  Repeat the tests from above.  This might  be able to generate the errors messages you are seeing since you now have a multi-process environment.  It is possible that you might need to increase the threads/processes more in order to generate enough over-head and disk accesses so that you can generate the delays and create the same conditions.  

This method should get you to the point of determining the contention level of the processes.

If you can get up to 10 (or what ever the magic number is) before you start to see contention and the hanging of the processes then you can mitigate this by setting up multiple back-end processes and load balancing between them ... they will have to be unique instances, not sharing the same files or code if this is the case.

Or you can contact the developers and see if they can come up with a fix  :)
Sander StadSysteemontwikkelaar, Database AdministratorCommented:
Did you place a firewall on the machine after the installation on the webserver.

You could try the to delete the entry from the following registrykey :

See http://support.microsoft.com/default.aspx?kbid=328306
This sounds like it might be a memory issue that is causing PHP to hang and not respond.
When this happens see what is running on the server.  If there are PHP processes running try aborting them and then see if the problem clears up.

If this works then it could be that PHP needs to be patched or there is a problem with the code that is running and something is hanging and possibly chewing up memory which eventually hangs the system.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

hc11Author Commented:
Thanks for your suggestions so far.

I don't believe there has been a firewall added to the machine. But if so surely this wouldn't cause the intermittent connection problem I described?

I just checked the machine while it was is this 'stuck' state. It had exactly the same number of php-cgi.exe threads running as when all is well (16 as set in Zend). They are all using the same amount of memory as they do when successfully serving pages (around 13MB). The processor utilisation of these threads was always at zero though, whereas when serving pages the threads that do the serving will jump from zero up to a few percent each briefly as they do their job.

The uncanny thing about this problem seems to be that while the machine is stuck and not serving pages the CPU load is much lower than when it is.
The only thing going on seems to be the errors adding to the App log.

Both the system and the data partitions have loads of free space.

Can anyone suggest anything else?

many thanks

hc11Author Commented:
Perhaps I should clarify. When I said:

"I don't believe there has been a firewall added to the machine. But if so surely this wouldn't cause the intermittent connection problem I described?"

I meant: If the firewall was a problem for the connection between the webserver and the db server then surely it would stop ALL connections rather than just some as I am seeing??

Sorry about the confusing double negative in the quoted comment.
hc11Author Commented:
Well. I have submitted a Zend support ticket since investigation on this forum was fruitless.

My take, this is a code issue.
it may not be a memory leak as opposed to a pice of code that is trying to use more memory than the process can handle.  If this happens then you get a small app that uses all of its memory but needs more so it is constantly doing memory checking to free up anything not in use and slowly (if at all) working on the request.  Now, if the request happens to center around file IO then this could hang the entire environment.  A lot of applications are single threaded when it comes to IO and disk access so if one of the 16 processes hangs while reading a file then as the other processes all get to the point of needing access to a file they will go into a wait state while the pending file access is to be completed ... which it probably never will.  Eventually all the processes will hang.

This can also be intermittent if the memory required by the "hung or slow" process is actually able to complete and then all the rest of the processes will catch up in their requests and everything goes back to normal.
hc11Author Commented:
Hmmm very interesting comment! Thank very much.
But the question is how to test this?? Increase the memory allocation to my php threads and see if it goes away?
Some code analysis tool?

thanks again

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.