none
first call to WCF services is slows (10 to 25 seconds) RRS feed

  • Question

  • Hi,

    We've been using WCF services for a new application being developed. We have several services for each group of features, however, we have the same problem with all of them: the first call is always very slow, it takes from 10 to 25 seconds. We tried the following:

    • Enable the startMode as "Always running", this in the IIS Manager.
    • Enable the autoStart (set "true"), also in the IIS Manager.
    • Disable the useDefaultProxy, this in the app.config.

    XML Serialization is not involved in our services and we don't use data contracts, so we haven't used the svcutil and I don't see this as a workound. This kind of issue wasn't present when using ASMX services, what else can we do to resolve this problem? Nothing I've been googling seems to help to resolve this inconvenient.

    I hope someone can help us with this issue that has been giving us nightmares. Thanks in advance.

    Best regards,

    César Campos

    Sunday, September 7, 2014 3:33 AM

Answers

  • Once again, thanks to both of you. I've doing some research and I found that it has something to do with the Channel Factory and its caching (or lack of), do you guys know something about this? I would be wonderful to find a way to cache the channel and stop having 20 seconds-long first calls. If I don't find something else, I'll take the solution proposed by darnold924 and put some service calling the web services. Thanks in advance.

    Regards,

    César Campos

    Saturday, September 13, 2014 1:12 AM

All replies

  • http://www.codeproject.com/Tips/114132/WCF-First-Call-Slow

    The other thing you can do is move the services over to a self-hosting a Net Tcp WCF service that is hit by the Web application running on IIS, That would be a backend server machine on the infrastructure that hosting the Net Tcp self-hosting WCF service. I have seen it done 

    Sunday, September 7, 2014 7:40 AM
  • Hi,

    Can you check the request information in fiddler or any other webservice request watcher?

    Because, in my thought , there is a URL resolving happened at first in your network before hitting the original Service IIS.

    Check the fiddler response of very first call and also with next subsequent calls. It will show you the exact problem and also showing the area of time consuming in between the service call.

    Other way , you needs to ensure all the major initialization are not happened in at first call. Initialize the component when ever you want access it in service call. It will save the initialization time at beginning call itself.



    prabakaran.M

    Sunday, September 7, 2014 5:21 PM
  • Thanks for the answer. We will study the possibility of using the hosting, however, we would like to remain the same way at least it's absolutely necessary.
    Monday, September 8, 2014 8:22 PM
  • Hi Prabakaran,

    I tried to use Fiddler, however, I wasn't able to track the WCF service calls.  I added:

    <configuration> <system.net> <defaultProxy> <proxy bypassonlocal="false" usesystemdefault="true" /> </defaultProxy> </system.net> </configuration>

    But it didn't work. I'll try to find another workaround to this problem. Any other solutions are welcomed, thanks both of you for your help.

    Best regards,

    César Campos

    Monday, September 8, 2014 8:27 PM
  • You can also just put a Ping() method in the service and have a Windows service on a timer ping the service periodically so it never inactive, becuase you are going to take the initial useage hit.
    Monday, September 8, 2014 8:39 PM
  • Hi Cesar,

    Fiddler is used to trace the request and responses other than local machine. so, try to consume you service in any one IIS or self hosting in any one of the server and try to access from your local then, you can trace the request and response and with details

    If you want to do the tracing for local services then, you should alter the code in the fiddler itself.

    refer the below URL. It is somewhat what complex

    http://blogs.telerik.com/fiddler/posts/13-01-08/capturing-traffic-from-.net-services-with-fiddler


    prabakaran.M

    Wednesday, September 10, 2014 4:54 AM
  • Once again, thanks to both of you. I've doing some research and I found that it has something to do with the Channel Factory and its caching (or lack of), do you guys know something about this? I would be wonderful to find a way to cache the channel and stop having 20 seconds-long first calls. If I don't find something else, I'll take the solution proposed by darnold924 and put some service calling the web services. Thanks in advance.

    Regards,

    César Campos

    Saturday, September 13, 2014 1:12 AM