views:

147

answers:

6

I've had sporadic performance problems with my website for awhile now. 90% of the time the site is very fast. But occasionally it is just really, really slow. I mean like 5-10 seconds load time kind of slow. I thought I had narrowed it down to the server I was on so I migrated everything to a new dedicated server from a completely different web hosting company. But the problems continue.

I guess what I'm looking for is a good tool that'll help me track down the problem, because it's clearly not the hardware. I'd like to be able to log certain events in my ASP.NET code and have that same logger also track server performance/resources at the time. If I can then look back at the logs then I can see what exactly my website was doing at the time of extreme slowness.

Is there a .NET logging system that'll allow me to make calls into it with code while simultaneously tracking performance? What would you recommend?

A: 

I would start by monitoring ASP.NET related performance counters. You could even add your own counters to your application, if you wanted. Also, look to the number of w3wp.exe processes running at the time of the slow down vs normal. Look at their memory usage. Sounds to me like a memory leak that eventually results in a termination of the worker process, which of course fixes the problem, temporarily.

Chris
A: 

I would start off with the following list of items:

  • Turn on ASP.Net Health Monitoring to start getting some metrics & numbers.
  • Check the memory utilization on the server. Does re-cycling the IIS periodically remove this issue (memory leak??).
  • ELMAH is a good tool to start looking at the exceptions. Also, go though the logs your application might be generating.
  • Then, I would look for anti-virus software running at a particular time or some long running processes which might be slowing down the machine etc., a database backup schedule...

HTH.

Sunny
A: 

You don't provide specifics of what your application is doing in terms of the resources (database, networking, files) that it is using. In addition to the steps from the other posters, I would take a look at anything that is happening at "out-of-process" such as:

  • Databases connections
  • Files opened
  • Network shares accessed

...basically anything that is not happening in the ASP.NET process.

BrianLy
+2  A: 

Every intermittent performance problem I ever had turn out to be caused by something in the database.

You need to check out my blog post Unexplained-SQL-Server-Timeouts-and-Intermittent-Blocking. No, it's not caused by a heavy INSERT or UPDATE process like you would expect.

I would run a database trace for 1/2 a day. Yes, the trace has to be done on production because the problem doesn't usually happen in a low use environment.

Your trace log rows will have a "Duration" column showing how long an event took. You are looking at the long running ones, and the ones before them that might be holding up the long running ones. Once you find the pattern you need to figure out how things are working.

JBrooks
I have some reason to believe that this is caused by something in SQL as well. Thanks for your answer, I'm going to check this out this week.
Steve Wortham
I may have found the problem. I had forgotten to set up an IP filter on the new server. So there were thousands of brute force log in attempts in the SQL logs. They are all failed attempts because fortunately I have a strong password. But there were times where there were over 20 login attempts in a second. I can only assume this was causing the slowness, but we'll see. I added an IP filter to Windows Firewall to put a stop to these login attempts.
Steve Wortham
By the way, I don't think that solved the slowness either. But I found something else today that I think may have finally done it. Anyway, to help me diagnose the problem and track the improvements I wrote a simple logger that I mention in my answer below.
Steve Wortham
Details, details....give us some details.
JBrooks
Oh, sorry. So all the details are at ServerFault here... http://serverfault.com/questions/131417/ipsec-policy-agent-flip-flopping-demand-start-auto-start-in-windows-server-2008/131489#131489
Steve Wortham
+1  A: 

IIS 7.0 has built-in ETW tracing capability. ETW is the fastest and least overhead logging. It is built into Kernel. With respect to IIS it can log every call. The best part of ETW you can include everything in the system and get a holistic picture of the application and the sever. For example you can include , registry, file system, context switching and get call-stacks along with duration.

Here is the basic overview of ETW and specific to IIS and I also have few posts on ETW

Naveen
A: 

Of course ultimately I just want to solve the intermittent slowness issues (and I'm not yet sure if I have). But in my initial question I was asking for a rather specific logger.

I never did find an answer for that so I wrote my own stopwatch threshold logging. It's not quite as detailed as my initial idea but it has the benefit of being very easy to apply globally to a web application.

Steve Wortham