Monitor the execution time of WCF and ASP. NET web API Interfaces

Source: Internet
Author: User

Software products often encounter such a situation: product performance is disturbed by unpredictable bottlenecks, resulting inProgramThe processing efficiency is reduced, and the performance is not fully utilized. How to quickly and effectively find the performance bottleneck of software products is one of the content we are interested in.

The performance counter is indeed a very powerful tool in Windows server. It allows you to learn the performance indicators of the server in a timely manner, so that you can know whether the server is running normally, it helps you analyze and locate possible server problems. For details, refer to the use of Windows performance counters (performancecounter) monitoring.

Install the three performance counters related to WCF together with. NET Framework 3.5. In the performance monitor, you can see these counters under servicemodelservice, servicemodelendpoint, and servicemodeloperation. You can choose to enable these settings for your application through configuration.

Service performance counters at the WCF performance counters level

The service performance counter measures the service behavior as a whole and can be used to diagnose the overall service performance. If you want to use performance monitor, you can find the service performance counter under servicemodelservice 3.0.0.0 performance object. Use the following mode to name a counter instance:

Servicename @ servicebaseaddress counters within the service range are aggregated from the counters in the end point set.

When a new instancecontext is created, the performance counters used to create the service instance increase progressively. Note that even when you receive an inactive message (through an existing service), or when you connect to an instance from a session, end the session, and then reconnect from another session, A new instancecontext will also be created.

Performance counters of WCF performance counters

You can use the endpoint performance counter to view the data that reflects how the endpoint accepts messages. When you use the performance monitor to view the performance, you can find the performance counter of the endpoint under the servicemodelendpoint 3.0.0.0 performance object. Use the following mode to name a counter instance:

(Servicename). (contractname) @ (endpoint listener address) data is similar to the data collected for a single operation, but it is aggregated only between endpoints.

Counters within the range of endpoints are aggregated from counters in the operation set.

NOTE: If two endpoints have the same protocol name and address, they are mapped to the same counter instance.

Operation Performance counters at the WCF performance counters level

If you want to use performance monitor, you can find the operation performance counter under servicemodeloperation 3.0.0.0 performance object. Each operation has a separate instance. That is, if the given protocol has 10 operations, 10 operation counter instances are associated with the Protocol. The object instance is named in the following mode:

(Servicename). (contractname). (operationname) @ (first endpoint listener address) This counter can be used to measure the call usage and operation execution.

When the counter is visible in multiple ranges, the data collected from the higher level of the range is aggregated with the data collected from the lower level of the range. For example, the CILS at the endpoint represents the sum of all operation calls within the endpoint, And the CILS of the Service Department represents the sum of all calls to all endpoints within the service.

Next, we will discuss how to monitor the execution time of the WCF and ASP. NET web API interfaces. Below are the solutions I found online.

Capturing WCF request execution time: collects statistics on the Interface execution time through the performance counter and dispatchmessageinspector.

Tracing in ASP. NET web API: Collects execution time using the trace function.

Http://www.strathweb.com/2012/11/realtime-asp-net-web-api-tracing-with-signalr/

Https://gist.github.com/3174719

Http://www.cnblogs.com/icuit/archive/2012/12/09/2810482.html

Http://dkochnev.blogspot.com/2011/06/wcf-framework-40-monitoring-service.html

Http://kleindublin.blogspot.com/2009/02/wcf-event-log-entry-servicemodelservice.html

Http://blogs.microsoft.co.il/blogs/idof/archive/2011/08/11/wcf-scaling-check-your-counters.aspx

Http://www.cnblogs.com/danielWise/archive/2011/02/22/1960320.html

WCF Service Performance monitoring using "perfmon"

Easily add performance counters to MVC applications

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.