Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple WCF calls take a lot of time

I am creating a WCF server-client application. However, in my first test, a simple call (the method basically just return true;) takes a lot of time (~5 seconds)

I tried to trace it, and here's a screenshot of the call trace enter image description here

As you can see between line 2 and 3 ther's a lapse of 5 seconds (although to be honest I don't know what line 2 and 3 means)

At the client's (caller's) configuration, the binding is like this (mostly generated by Visual Studio

    <wsHttpBinding>
        <binding name="WSHttpBinding_IAgent" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="None">
          </security>
        </binding>
      </wsHttpBinding>

and at the server

<wsHttpBinding>
    <binding name="WSHttpBinding_IAgent" closeTimeout="00:01:00"
      openTimeout="00:01:00" receiveTimeout="00:05:00" sendTimeout="00:05:00"
      bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
      maxBufferPoolSize="16777216" maxReceivedMessageSize="16777216"
      messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
      allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="16777216"
        maxArrayLength="16384" maxBytesPerRead="16384" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00"
        enabled="false" />
      <security mode="None"/>
    </binding>

And the way I call it something like this

var client = new AgentClient(binding, BuildEndpointAddress(hostName, port));
for(int i =0; i<10; i++)
    client.IsAlive(); //this call is very slow despite just returning true;
    // subsequent calls are also slow so probably not because of wake-up time

Note for this test, both server and client are in the same computer so it couldn't be a network issue. Any idea what's causing the slowness or how I can find more information to troubleshoot this?

like image 867
Louis Rhys Avatar asked Jun 04 '12 05:06

Louis Rhys


1 Answers

Application lifetime is not specified in your post and I will assume that you start the client app and call WCF service at first time without warming it up.

Timing will make sense in that case.

.NET does lots of hidden work to initialize ChannelFactory and Server if it was not warmed up despite using of lightweight binding and message.

That is nature of WCF and should not cause much issues because after warming up communications are really fast.

Try to call your service two times in a row in one app session measuring time for both calls. If both calls take comparable time my assumption is wrong.

In case you would like to see my question and compare environment -

Why is the first WCF client call slow?

like image 184
Dmitry Harnitski Avatar answered Oct 20 '22 10:10

Dmitry Harnitski