Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Web API performance issue

I have a simple Web API that returns the list of contacts:

public class ContactsApi : ApiController
{
    public List<Contact> GetContacts()
    {
        Stopwatch watch = new Stopwatch();
        watch.Start();
        // Doing some business to get contacts;
        watch.Stop();
        // The operation only takes less than 500 milliseconds
        // returning list of contacts
    }
}

As I've used Stopwatch to test data-retrieval performance, it's apparent that it takes less than a second. However, when I issue a request to the GetContacts action via Chrome browser, it takes 4 to 5 seconds to return data.

enter image description here

Apparently that delay has nothing to do with my data-retrieval code. It seems to me that Web API is running slow. But I have no idea how to debug and trace that.

Is there any utility to log timing for ASP.NET HTTP request process pipeline? I mean, something like Navigation Timing to show that each event has occurred in what time?

like image 906
Ali RAN Avatar asked Nov 12 '13 05:11

Ali RAN


1 Answers

How big is your response? Maybe it is a cost of serialization and transfer? However, there is a lot of possibilities to profile it, I would start from profiling with one of the tools in the market like ANTS Performance Profiler or dotTrace

like image 160
Konrad Kokosa Avatar answered Sep 30 '22 14:09

Konrad Kokosa