Essential Dot NET Performance Counter

For list of others essential performance counters for applications based on Windows platform see here.

When there is a requirement of collecting performance counters during performance testing, it becomes tough to select few counters from existing many.  All counters are important in its context and cannot be simply ignored.  So, it is very important to recheck the list of counters that needs to be monitored before every performance run.  You might need to change the counters as per yours requirements.

Following are some of the Dot NET counters, that I find bare essential to start with though.  The list of counters and its preferred  / threshold values are being collected from multiple relevant blogs / links and have been mentioned in the ‘References’ section below.


Performance Object
Performance Counter
Preferred Value
Exception
# of Exceps Thrown / Sec
< 5% of RPS (Requests / sec)
Loading
Rate of assemblies
None
Lock & Thread
Contention Rate / Sec
0 or very low
Current Queue Length
None
Memory
# Gen 0 Collections
10 * # Gen 1 Collections
# Gen 1 Collections
1/10th of Gen 0 Collections
# Gen 2 Collections
1/10th of Gen 1 Collections
# Induced GC
As low as possible
# of Pinned Objects
< 100
% Time in GC
< 5%
Gen 0 Promoted Bytes/Sec
As low as possible
Gen 1 Promoted Bytes/Sec
As low as possible
Large Object Heap size
As low as possible


Exception
Describe the performance counters that provide information about the exceptions thrown by an application.

# of Exceps Thrown / Sec
It displays the number of exceptions thrown per second. It includes both .NET exceptions and unmanaged exceptions that are converted into .NET exceptions.
Preferred Value:  < 5% of RPS (Requests / sec)
Threshold Value:  > 100
Notes:
  1. Correlate this metric with ASP.NET applications \ Requests per second.  Don't use _Global_ counter and use specific application though. Graph can be plotted against Elapsed Time vs. (Requests / sec, # Exceps Thrown / sec) and can be figured out if exceptions are occurring because of number of requests increasing or while running for a longer duration or exception happening from the start. If exceptions rate is higher from start then it might indicates programmer are throwing exception as part of normal processing.
  2. The total number of managed exceptions thrown per second. As this number increases, performance degrades.
  3. Exceptions should not be thrown as part of normal processing.
  4. Response.Redirect, Server.Transfer, and Response.End all cause a ThreadAbortException to be thrown multiple times, and a site that relies heavily upon these methods will incur a performance penalty.


Loading

1.       Describes the performance counters that provide information about assemblies, classes, and application domains that are loaded.
2.       The _Global_ counter instance should not be used with these performance counters, because it is updated by all managed processes. Instead, use the aspnet_wp instance.

Rate of Assemblies
It displays the number of assemblies loaded per second across all application domains
Preferred Value:  None
Threshold Value:  None
Notes:
  1. Correlate 'Rate of Assemblies' with 'Memory Availability'.  If memory is being used because of increasing loading of assemblies then it can be recommended to load less number of user controls in an aspx page.
  2. If the assembly is loaded as domain-neutral from multiple application domains, this counter is incremented only once.


Lock & Thread

Describes the performance counters provide information about managed locks and threads that an application uses.

Contention Rate / Sec
Displays the rate at which threads in the runtime attempt to acquire a managed lock unsuccessfully
Preferred Value:  0 or very low
Threshold Value:  See preferred value
Notes:
  1. Unsuccessful locks can cause serious performance issues when the rate is high, as the threads are not only synchronized but ultimately unsuccessful, potentially throwing exceptions and waiting excessively.
Current Queue Length
Displays the total number of threads that are currently waiting to acquire a managed lock in the application
Preferred Value:  None
Threshold Value:  None
Notes:
  1. Presence of queue in a system definitely gives an hint of waiting.  But no waiting also means the resources are not being utilized properly, so queue should always be correlated with utilization too.



Memory
Describes the performance counters provide information about the garbage collector

# Gen 0 Collections
Displays the number of times the generation 0 objects (that is, the youngest, most recently allocated objects) are garbage collected since the application started.
Preferred Value:  10 times more than #Gen 1 collections
Threshold Value:  See preferred value
Notes:
  1. The number of times generation 0 objects have been garbage collected. Objects that survive are promoted to generation 1.
  2. A collection is performed when room is needed to allocate an object, or when someone forces a collection by calling System.GC.Collect. Collections that involve higher generations take longer, since they are preceded by collections of lower generations.
  3. The # Gen N Collections counters and the % Time in GC counter are the best for identifying performance issues caused by excessive allocations.
# Gen 1 Collections
Displays the number of times the generation 1 objects are garbage collected since the application started.
Preferred Value:  See threshold value
Threshold Value:  1/10th of # Gen 0 collections
Notes:
  1. Objects that survive are promoted to generation 2.
# Gen 2 Collections
Displays the number of times the generation 2 objects are garbage collected since the application started.
Preferred Value:  See threshold value
Threshold Value:  1/10th of # Gen 1 collections
Notes:
  1. Generation 2 is the highest, thus objects that survive collection remain in generation 2.
  2. Gen 2 collections can be very expensive, especially if the size of the Gen 2 heap is excessive.
# Induced GC
Displays the peak number of times garbage collection was performed because of an explicit call to GC.Collect.
Preferred Value:  As low as possible
Threshold Value:  See preferred value
Notes:
  1. It is good practice to let the garbage collector tune the frequency of its collections
  2. If # induced GC is increasing and indicates a high number then it indicates a problem.  It is never a good idea to induce GC explicitly rather it is should be found out that why heap size is growing.
# of Pinned Objects
Displays the number of pinned objects encountered in the last garbage collection.
Preferred Value:  Less than 100
Threshold Value:  See preferred value
Notes:
  1. A pinned object is one that the garbage collector cannot move in memory.
  2. This counter tracks the pinned objects only in the heaps that are garbage collected.
  3. If number of pinned objects are large in number (more than 100) or constantly increasing, it indicates problems related to programming and incoming memory issue
% Time in GC
Displays the percentage of elapsed time that was spent performing a garbage collection since the last garbage collection cycle
Preferred Value:  Less than 5%
Threshold Value:  An average of 5% or more; short-lived spikes larger than this are common.
Notes:
  1. All threads are suspended during a garbage collection.
  2. More GC collections means less real work
  3. The most common cause of a high % Time in GC is making too many allocations on a per request basis.
  4. The second most common cause is inserting a large amount of data into the ASP.NET cache, removing it, regenerating it, and reinserting it into the cache every few minutes.
  5. Avoid allocating short-lived objects larger than 85,000 bytes. These objects are allocated in the large object heap, and are more expensive to collect.
Gen 0 Promoted Bytes/Sec
Displays the bytes per second that are promoted from generation 0 to generation 1
Preferred Value:  As low as possible
Threshold Value:  See preferred value
Notes:
  1. Memory is promoted when it survives a garbage collection.
  2. This counter is an indicator of relatively long-lived objects being created per second.
  3. If this value is large than it means lots of long-lived objects are being created per second and it needs to be looked into it whether they can be disposed early or not.
Gen 1 Promoted Bytes/Sec
Displays the bytes per second that are promoted from generation 1 to generation 2
Preferred Value:  As low as possible
Threshold Value:  See preferred value
Notes:
  1. Objects that are promoted only because they are waiting to be finalized are not included in this counter.
  2. This counter is an indicator of very long-lived objects being created per second.
  3. Nothing is promoted from generation 2 because it is the oldest generation.
Large Object Heap size
Displays the current size, in bytes, of the Large Object Heap
Preferred Value:  As low as possible
Threshold Value:  See preferred value
Notes:
  1. Objects greater than 20 KB are treated as large objects by the garbage collector and are directly allocated in a special heap; they are not promoted through the generations.
  2. If this value is increasing, it indicates lots of BLOBs are getting creating and which needs to be looked into it.

References:





Comments

Post a Comment

Popular posts from this blog

Performance Test Run Report Template

Bugs Management in Agile Project

Understanding Blockchain