views:

127

answers:

1

I have a WCF service installed on IIS7. I noticed that the first call to my service is always very very slow. The subsequent calls are much faster & acceptable.

If there are no calls made to the service for some time, it again goes to sleep mode. After this the next call again takes a long long time.

Any remedies for this problem?

TIA.. Sharjeel

+2  A: 

It is because of process management on IIS. When there are no calls for certain period of time IIS release the recourses and stops the process. This is why you can notice that it is slow for first request and for requests after a long delay. Because while the first request or after long period of silence IIS loads everything from scratch. JIT complier runs and etc...

Also note : When you are hosting WCF services on IIS, the WCF services enjoy all the features of ASP.NET applications. You have to be aware of these features because they can cause unexpected behavior in the services world. One of the major features is application recycling, including application domain recycling and process recycling. Through the IIS Management Console, you can configure different rules when you want the recycling to happen. You can set certain thresholds on memory, on time, and on the amount of processed requests. When IIS recycles a worker process, all the application domains within the worker process will be recycled as well

If you need automatic starting: The Windows Service Control Manager allows you to set the startup type to automatic, so that as soon as Windows starts, the service will be started, without an interactive logon on the machine. So you can use Windows service as a host.

More details you can check in Hosting and Consuming WCF Services.

Incognito
Sharjeel Ahmed
@Sharjeel Agreed I really noticed that :).
Incognito