genxgeek
genxgeek

Reputation: 13377

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>

Upvotes: 0

Views: 1460

Answers (1)

Giorgio Minardi
Giorgio Minardi

Reputation: 2775

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.

Upvotes: 1

Related Questions