Webserver hangs connecting to SQL2005.

Posted on 2009-02-19
Medium Priority
Last Modified: 2013-12-12
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....
Question by:hc11
  • 4
  • 3

Expert Comment

by:Sander Stad
ID: 23689411
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
LVL 22

Expert Comment

ID: 23692647
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.

Author Comment

ID: 23703397
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.


Author Comment

ID: 23704686
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.

Author Comment

ID: 23783073
Well. I have submitted a Zend support ticket since investigation on this forum was fruitless.

LVL 22

Expert Comment

ID: 23783632
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.

Author Comment

ID: 23789754
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

LVL 22

Accepted Solution

cj_1969 earned 1500 total points
ID: 23795102
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  :)

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question