简体   繁体   中英

How to track performance of mvc4 web api rest call?

I have an asp.net mvc4 web api (rest) interface that is being called by numerous clients. Basically I serve up content per certain params:

http://myserv.x.com/api/123/getstuff?whatstuff=thisstuff

My question is that it gets hit about 50K a day and I am noticing timeouts and slow response times every now and then.

ASK: How can I include metrics of how long the request took to process (internal to my code) as well as how long it took to get serviced in the IIS queue. I'm not sure if the latency is in my code or IIS.

I'd like to add them back within the response somehow:

<StuffPayload>
  <Stuff id=1 url=http://myserv.x.com/img/1/>
  <Response time=100ms IIStime=10ms MyServerCodeTime=90ms/>
</StuffPayload>

First check what is your method doing: if there's any sql/file operation ensure you create/dispose correctly all resources. You could write custom action filters for logging so you can have a reusable peace of code for all your tracing. You can then add additional content to the response within the OnActionExecuted method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM