Performance Counters

Performance counters are strange beasts but can be quite useful in order to keep an eye on how custom code is performing in a production environment, and can be invaluable to support staff or infrastructure teams in diagnosing potential causes of system resource issues.

There are a few 'gotchas' though and I will try to list as many of them as I can recall:
  1. Creating a new performance counter category should ideally be done by a separate utility as the new category cannot be used by your custom code directly after it has been created. Also the process creating the counter categories must have write access to the registry.

  2. Counter values will expire after the allotted time interval, so for example an AverageTimer counter type needs to be populated at least once every second otherwise you end up with zero values (and an ugly chart when using perfmon).

  3. Choosing the correct counter type is important, and remember that a lot of the hard work is done for you all you need to do is supply the raw data. For example, frequency of operations can be counted by incrementing a RateOfCountsPerSecond32 every time the event happens, and will automatically give you data on how often it happens per second.

  4. Instances. These are particularly useful when finer granularity is required for a counter. Examples of these are the Process counters that allow you to monitor data such as ProcessorTime for each process running on a machine. It is important to note though that instance counters are of the type MultiInstance and cannot be mixed with SingleInstance counters in the same category.


Get all of this right and you can monitor your custom code in perfmon:

PerfMon Chart showing average login times for 3 users
PerfMon Chart showing average login times for 3 users


Comments

Popular posts from this blog

Kerberos setup for SharePoint 2013

Claims with NTLM and authentication prompts