3

I have a WCF web service hosted in IIS using HTTPS. Both the service and client app are written in C#. The first web service call that the client app makes takes over 15 seconds to complete. Once that initial call is made, subseqent calls complete in about 100 milliseconds. For testing, I have a simple method: string Ping(int val); that simply echoes back the number passed in as a string.

The odd thing is that a user a thousand miles away reported this problem but I was not experiencing it on my development machine. I was only seeing the first request taking 2 to 3 seconds. Now virtually every client is reporting that the first request takes more than 15 seconds.

Is this normal behavior for a C# client? Has anyone experienced this problem?

My web service binding is configured as follows:

<basicHttpBinding>
  <binding
    name="BasicHttpBinding_IMyWebSvc"
    maxBufferSize="16777216"
    maxReceivedMessageSize="16777216"
    messageEncoding="Mtom">
    <readerQuotas
      maxDepth="1024"
      maxStringContentLength="262144"
      maxArrayLength="16777216"
      maxBytesPerRead="16777216"
      maxNameTableCharCount="16777216"
    />
    <security mode="Transport">
      <transport clientCredentialType="None"/>
    </security>
  </binding>
</basicHttpBinding>

Edit: This problem gets weird.

I wrote a test client using trimmed down proxy code that had nothing but the Ping() test method. Ran the test and it still took >15 seconds. Started changing the clients buffer sizes since the Ping() function does not need large buffers and the problem went away. Restored the buffer sizes to their original values and the problem did NOT come back. Ran the real client and the first call completed in 1.2 seconds. Now I cannot reproduce the problem on my development PC.

Robin Vincent
  • 61
  • 1
  • 6
  • Have you used Wireshark to look at where the delay is coming from in terms of the network? – Jon Skeet Dec 17 '11 at 18:05
  • If you're able to wireshark from outside the network hosting your service that might be better. I'm on board with Jon, I think you're having issues with some sort of network related timeout. – Kenneth Ito Dec 17 '11 at 18:25
  • According to Wireshark, no packets left the client for 14 seconds after issuing the request. My development client is a high end PC, made for gaming. I will investigate what is going on during client construction. – Robin Vincent Dec 17 '11 at 19:38

3 Answers3

0

Problem in hosting .NET applications on IIS is with application pool warm up time. After pool has been terminated (after idle time or bin-files modification), it's not recreated until next request. You can keep you app pool active using IIS Application Warm up module for IIS (you can install it using Web Platform Installer)

Novakov
  • 3,055
  • 1
  • 16
  • 32
0

If you are using a WCF proxy in your client, the time required to generate the proxy plumbing will make the first call slower than subsequent calls. See this article for more info.

Jason
  • 86,222
  • 15
  • 131
  • 146
  • I am using .NET Framework 4 and used svcutil.exe to generate proxy. I will check out article and see if anything there helps. – Robin Vincent Dec 17 '11 at 19:40
  • Am already doing what article recommended except I used constructor with binding and endpoint. Made a test app to use constructor with no args and get same results. – Robin Vincent Dec 17 '11 at 23:37
0

Check the answer on this previous question, it is related to asmx services, but the core issue may be the same

ASMX Web Service slow first request

Community
  • 1
  • 1
curtisk
  • 19,950
  • 4
  • 55
  • 71
  • All the answers for the above issue seem to be geared toward improving service startup time. I have verified that the problem is on the client side. – Robin Vincent Dec 18 '11 at 22:40