We help IT Professionals succeed at work.

using performance counters in asp.net (vb). What kind of useful information can I get?

Medium Priority
456 Views
Last Modified: 2012-05-12
Hi,

Just want to learn a bit about performance counters in vb.net website. I created something like below and was able to display the results in a gridview ok.

So, the only problem is I don't really know what I'm looking at or what use it is. And I don't really know what I should be looking at. Seems hard to find useful info in google on this.

Any info on this?

Thanks, Aiden
Dim perfAppRestarts As New PerformanceCounter("ASP.NET", "Application Restarts")
      Dim perfFreeMem As New PerformanceCounter("Memory", "Available MBytes")
      Dim perfRequestBytesOutTotal As PerformanceCounter = New PerformanceCounter("ASP.NET Applications", "Request Bytes Out Total", "__Total__", True) 'Readonly True

Open in new window

Comment
Watch Question

Author

Commented:
Hi thanks, but that doesn't really help. I can find information on performance counters... I'm just not sure how to interpret it and how I can use this information to improve my app or find errors / bugs / bottlenecks.

For instance, one site was saying to use the performance counters below (or some of them). And you can see I have some info on them. Great. But, how does that help me exactly? Most of those counters appear to be equal to zero on the server anyway....

Dim perfAppRestarts As New PerformanceCounter("ASP.NET", "Application Restarts") 'The number of times that an application has been restarted. This counter increments with each Application_end event but is reset if IIS is restarted.
      Dim perfRequestsQueued As New PerformanceCounter("ASP.NET", "Requests Queued") 'The number of requests waiting for service
      Dim perfRequestsSec As New PerformanceCounter("ASP.NET Applications", "Requests/Sec", "__Total__", True) 'Readonly True 'The number of requests executed per second.
      Dim perfFreeMem As New PerformanceCounter("Memory", "Available MBytes")
      Dim perfRequestBytesOutTotal As New PerformanceCounter("ASP.NET Applications", "Request Bytes Out Total", "__Total__", True) 'Readonly True
      Dim perfErrorsTotal As New PerformanceCounter("ASP.NET Applications", "Errors Total", "__Total__", True) 'Readonly True 'The total number of errors that occurred during the execution of HTTP requests
      Dim perfErrorsTotalSec As New PerformanceCounter("ASP.NET Applications", "Errors Total/Sec", "__Total__", True) 'Readonly True 'The number of errors per second.
      Dim perfPipeline As New PerformanceCounter("ASP.NET Applications", "Pipeline Instance Count", "__Total__", True) 'Readonly True 'The number of active pipeline instances.
      Dim perfExceptions As New PerformanceCounter(".NET CLR Exceptions", "# of Exceps Thrown", "_Global_", True) 'Readonly True 'The total number of exceptions thrown.
      Dim perfContextSwitchesSec As New PerformanceCounter("System", "Context Switches/Sec") 'A context switch occurs when the kernel switches the processor from one thread to another, for example, when a thread with a higher priority than the running thread becomes ready. Context switching activity is important for several reasons. A program that monopolizes the processor lowers the rate of context switches because it does not allow much processor time for the other processes threads. A high rate of context switching means that the processor is being shared repeatedly, for example, by many threads of equal priority. A high context-switch rate often indicates that there are too many threads competing for the processors on the system.

Open in new window

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:

Author

Commented:
Hi sorry a lot of stuff there so only found the time to read through now. So, there's lots of stuff on performance counters there, but really only on how to create your own performance counter to measure something that you want to measure.

But it still doesn't talk about which performance counters are useful for measuring the performance of your website, or what kind of performance counters you should create in order to measure performance of your website. So, I'm really still in the same situation of not really knowing how to get the best out of performance counters.

I suppose I could create a counter which measures how often a page is hit (and then show that value per day over the last week)... or something like that... but one of those pages was suggesting that you shouldn't run in production anyway, so I don't want to create something that will not be useful on going or that will affect performance unnecessarily (as I'm just curious really). So, just want the basics on what it is I should measure and how to interpret that
Programmer
Commented:
Well to keep things simple, we just use performance counters to diagnose the health of the website from the perspective of the server. For example, how hard is the processor working to handle requests, how much space on the disk, how much memory are we using, how many client connections to the web server, how hard is SQL server working. We use these tools to make sure that our websites stat healthy like a doctor has his tests to make sure a patient stats healthy. Unless you are operating a large environment with a webfarm for example, you don't have to worry about creating a programmatically .net dashboard. You can simple go to computer management on the server and view all these reports, I also use event viewer. There is plenty on google on how to implement code if you want, but most just want to create a dashboard in large environments.

Does this help?
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014

Commented:
Did you read the 3rd link?

Author

Commented:
ok think maybe i'm getting it now. Codecruiser, yeah I read that, but it still didn't click with me as I was thinking in terms of programatically dealing with these performance counters, in which case I was getting zero for most of those values as I just printed them out to a gridview (but not over a particular time frame)... but as GlobaLevel points out, maybe that's only useful for absolute values (maybe such as application restarts or I don't know what).

So, ok, I've seen those counters in action from the 3rd link. One question though... three of them (anonymous requests, requests total and requests succeeded) don't have a baseline of zero so I can see that they build up as requests come in. But, when do they start at zero? Is it after an application rest, or an iis reset or something?

GlobaLevel, what you're talking about sounds perfect... so what performance counters do you use? I should just add these then to the performance monitor or do I need to do some manipulation?