Monitoring .NET application performance using "Perfmon" is not very new to developers. The same tool can be used to monitor WCF service performance also.
Using the code
Attached a C# solution "PerfCounter" with the article. There are three projects included in it
- PerfCounter: It is a default template project that is created when you add new WCF Service library project with GetData method.
- PerformanceCounterService: It is a Windows Service Host for "PerfCounter". You can compile and install this as a windows service refer to article for any help : http://www.codeproject.com/Tips/52471/Install-Windows-Service
- PerformanceCounterClient:It is a console application to see performance counter working
What is “Perfmon”
Perfmon is a performance analysis and troubleshooting tool. It is able to collect a various performance metrics over time, at specified intervals, and generates logs that can be graphically analyzed to identify problem areas in your system performance.
PerfMon Sample: Demonstrates How to Monitor System Performance Using Performance Counters - http://msdn.microsoft.com/en-us/library/aa645516(v=vs.71).aspx
How to use Perfmon
Go to Windows > RUN
Type “Perfmon” and press enter this will open Performance Monitor as shown in image below.
Open content menu on Graph in the left side and click “Add Counters” this will open a window with various performance counter categories as shown in below image
WCF Service and performance counters
WCF service has number of in build performance counter exposed, which can be used to monitor WCF service. By default the WCF performance counter are turned off because the counter have potential to increase the memory footprint of the WCF application significantly.
WCF Service performance counter categories:
The group of counters is responsible for tracking information about the endpoints for a WCF service. See below screen where PERFCOUNTER service has ServiceModelEndPoint performance counters enabled. Counters can be added for monitoring of all endpoints or specific endpoint of a WCF service.
The group of counters is responsible for tracking information about the operations within a WCF service. See below screen where PERFCOUNTER service has ServiceModelOperation performance counters enabled. Counters can be added for monitoring of all operations or for specific operation of a WCF service.
The group of counters is responsible for tracking information about the WCF service as a whole. See below screen where PERFCOUNTER service has ServiceModelService performance counters enabled.
Enable performance counter for a WCF service
To enable performance counter for a WCF service modify service host’s configuration file to have diagnostic configuration tag with following possible values.
WCF service performanceCounter configurations can be set to following three values
- performanceCounters=”All”, this enables all three categories of counters
performanceCounters=” ServiceOnly”, only ServiceModelService category counters are enabled
performanceCounters=” Off”, all ServiceModel performance counters are disabled. This is the default value.