none
How to avoid that first call taking a lot of seconds? RRS feed

  • Question

  • Hi,

    I'm having a lot of troubles calling WCF services because the first call takes a lot of seconds (up to 30 seconds now) and that time is not tolerable. Some facts:

    • Services hosted in IIS 7.0 using application pools in integrated mode (.net 4.0), autostart mode, 32-bits apps enabled, no other parameter modified.
    • We have like 10 WCF services, each one for every set of features.
    • No xml serialization is used in the services.
    • We add the reference to the service in the client application, instantiate the service client, we open it, we use it, and then we close it. No channel factory or proxy caching.
    • It seems like we have not network issues, it's just the first call, the next call is always fast (1 to 3 seconds).
    • I tried using the [WorkerThreadPoolBehavior] in one of my services with no results.
    • I tried using the factory.createChannel() instead of the instantiation explained above with no results.
    • We use basic binding when calling the services.
    • Our client application and the services are compiled with .net 4.0.
    • The services become iddle after 10 to 30 minutes.

    I've been looking all over the internet, applying different solutions and nothing has worked. What else could I do to improve the initialization time at the first call? I'm aware that some loading is going on at the first call but is anything else I could do to pre-load something? Thanks in advance.

    Regards,

    César

    Saturday, September 13, 2014 3:14 PM

Answers

  • The Web service gets compiled on a first time or initial usage by a client. So that's why it takes so long by the initial usage of the service by a client. After it compiles, then it says in memory until it stays inactive for 20 minutes I believe and it goes out of scope. It has to be compiled again if it goes out of scope and a client again tries to access the service again.

    You may have to things you can do.

    1) Have a Ping method in the service and have a Windows service ping the service prodically to keep the Web service in memory.

    2) Make the WCF service a TCP/IP service, a self-hosting exe service, that is always running on a backend machine. The Web clients on a front-end server would access the TCP WCF service on a backend server.

    Sunday, September 14, 2014 7:30 AM

All replies

  • The Web service gets compiled on a first time or initial usage by a client. So that's why it takes so long by the initial usage of the service by a client. After it compiles, then it says in memory until it stays inactive for 20 minutes I believe and it goes out of scope. It has to be compiled again if it goes out of scope and a client again tries to access the service again.

    You may have to things you can do.

    1) Have a Ping method in the service and have a Windows service ping the service prodically to keep the Web service in memory.

    2) Make the WCF service a TCP/IP service, a self-hosting exe service, that is always running on a backend machine. The Web clients on a front-end server would access the TCP WCF service on a backend server.

    Sunday, September 14, 2014 7:30 AM
  • Hi,

    I ended up using this approach, though, is just a workaround and a serious problem Microsoft should be dealing with. Thanks again, darnold924.

    Regards,

    César Campos

    Wednesday, October 22, 2014 3:39 PM