Performance Counters Timeouts and Load Testing with Visual Studio 2008
While using Visual Studio 2008 to do a load test of a SharePoint web site, I was having problems retrieving performance counters from the servers that I was trying to test. The tests were configured as local tests without a test rig. After I setup the web test and load test, the first time that I ran the test, everything was fine. I got values from the performance counters on the servers and my graphs showed the information that I wanted. Every test that I ran afterwards though, I was lucky if I got performance counter results from anything other than the local machine that was executing the test.
When the tests were run, I could see that there were 3 errors. Clicking on the error to see more details gave me a window with an error message like:
The performance counter category ‘Memory’ cannot be accessed on computer ‘WEB01’ (Timed out trying to read performance counter category ‘Memory’ on computer ‘WEB01’); check that the category and computer names are correct.
Searching on the web for this error message I could not find a whole lot, at least nothing that seemed useful. After I while I started finding some blog posts that would give little bits and pieces that I used to help me along the way. This blog takes all of those bits and pieces and puts them all together. [References at the end]
One of the first things that I tried was to make sure that I could retrieve the performance counters from the remote servers from my local machine. I opened Performance Monitor and added counters from the remote servers. Event though it took a minute to enumerate the list of counters after connecting to the server, all seemed well. At this point, I decided to start a load test from Visual Studio while performance monitor was already connected to the machine. As soon as I started the load test performance monitor froze for several seconds.
Either turn off the local firewall or enable the rules for Performance Logs and Alerts in the Windows Firewall with Advanced Security snap-in.
Performance Monitor Users Local Security Group
Make sure that the user account that VSTestHost.exe runs as is a member of the Performance Monitor Users local security group on the server that is being monitored.
Enable logging for the VSTestHost.exe
Open the file VSTestHost.exe.config in the folder C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE and add the following:
<trace autoflush="true" indentsize="4">
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="c:\VSTestHost.log" />
<!– You must use integral values for "value". Use 0 for off, 1 for
error, 2 for warn, 3 for info, and 4 for verbose. –>
<add name="EqtTraceLevel" value="3" />
Increase the Counter Timeouts
Open the file VSTestHost.exe.config in the folder C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE and add the following (sets a 1 minute timeout):
<add key="LoadTestCounterCategoryReadTimeout" value="60000"/>
<add key="LoadTestCounterCategoryExistsTimeout" value="60000"/>
Connect to the IPC$ Share on the Remote Machine
Create a persistent connection to the remote server.
net use \\web01\ipc$ /user:domain\user /persistent:yes
Open the command prompt and use the typeperf.exe command-line utility to query the counters on the remote machine.
typeperf –q –s web01
I realized that I was on the right track when it took almost 10 minutes to retrieve the list of counters. At this point, I went to talk to the Microsoft TAM that is on-site with the client. He tried the same thing but since he was having name resolution issues from his machine, he used the IP address instead of the host name and instantly got results to my amazement. I quickly went back to my desk and tried the same thing and it worked. I then tried it by host name and it worked also.
typeperf –q –s 192.168.1.100
Everything continued to work fine until I rebooted my workstation. After rebooting the workstation I had to re-connect to the IPC$ share and run typeperf with the IP address.