locked
Slow performance on the initial call using CloudTableClient RRS feed

  • Question

  • I've noticed very slow performance when I run the code below... the second line takes 6 - 8 seconds to execute:

    var cloudTableClient = new CloudTableClient(storage.TableEndpoint.AbsoluteUri, storage.Credentials);
    cloudTableClient.CreateTableIfNotExist("AzureStorageJobStatus");
    
    

    If I remove the call to CreateTableIfNotExist, the next operation on cloudTableClient will take 6-8 seconds... so it appears that the first operation is always slow, and after that is much faster.

    Is this typical? If not, does anyone have any suggestions on what can be done to improve this?

    Thanks

    Thursday, October 13, 2011 9:36 PM

Answers

  • Hi,

    I’m unable to reproduce this issue on my side. Are you testing locally or in the cloud? If you’re testing locally, try to deploy the service to the cloud, and see if you still have the problem. You can use a Stopwatch to monitor how long does it to make the request to table storage.

    In addition, if the problem only occurs the first time you make the request, you can put the code in Application_Start in Global.asax. Generally it doesn’t matter if your service takes several seconds longer to start. But it matters if it takes a long time to process client requests.

     

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    Friday, October 14, 2011 7:23 AM

All replies

  • Could it be a DNS resolution problem? Try resolving the address beforehand to see if that's the lengthy operation. For example, insert the following call to GetHostAddresses after the line that creates the CloudTableClient.

    var addresses = System.Net.Dns.GetHostAddresses(storage.TableEndpoint.Authority);
    

    Friday, October 14, 2011 4:00 AM
  • Hi,

    I’m unable to reproduce this issue on my side. Are you testing locally or in the cloud? If you’re testing locally, try to deploy the service to the cloud, and see if you still have the problem. You can use a Stopwatch to monitor how long does it to make the request to table storage.

    In addition, if the problem only occurs the first time you make the request, you can put the code in Application_Start in Global.asax. Generally it doesn’t matter if your service takes several seconds longer to start. But it matters if it takes a long time to process client requests.

     

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    Friday, October 14, 2011 7:23 AM
  • Thanks Fernando...

    It does not appear to be DNS. I added your line of code right after creating the CloudTableClient. DNS resolution took 158ms and CreateTableIfNotExists still takes 6 - 8 seconds.

    I did some inspection and the time spent appears to be distributed in different areas. The most expensive trace ends in a call to System.Net.WinHttpWebProxyFinder.WinHttpGetProxyForUrl. This takes just over 2 seconds.

    Another expensive step is a call to System.Data.Services.Client.DataServiceQuery<TElement>.get_QueryComponents(). Also takes over 2 seconds.

    Friday, October 14, 2011 11:59 AM
  • I'm taking the measurements locally, but when I run the application on the cloud the duration appears to be the same.

    I don't have as much visibility about the details... creating an isolated application is a good idea.

    At this point, I like your idea of creating the client in the application start. I'm assuming that since the underlying connection is done through REST, there are no connections or other resources that would expire after a long time.

    I'll let you know how this works, thanks.

    Friday, October 14, 2011 12:02 PM
  • Hi,

    Is the issue resolved? For now, I will mark the reply as an answer. If you find it no help, please feel free to unmark it and follow up.

    Thanks.

     

    Best Regards,

    Ming Xu.


    Please mark the replies as answers if they help or unmark if not.
    If you have any feedback about my replies, please contact msdnmg@microsoft.com.
    Microsoft One Code Framework
    Wednesday, October 19, 2011 5:28 AM
  • Hi Ming Xu,

    Yes... the issue was resolved, thank you.

    I couldn't create an instance of the client that can be shared in the Application_Start, because that class is not thread-safe.

    However, it appears that by simply creating an instance and then dropping it will help speed up any subsequent initializations.

    Thanks.

    Wednesday, October 19, 2011 11:32 AM