Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Performance Slow for the first call

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?

like image 637
Sharjeel Ahmed Avatar asked Jul 28 '10 08:07

Sharjeel Ahmed


2 Answers

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.

like image 197
Incognito Avatar answered Nov 18 '22 13:11

Incognito


There is another approach through which you can make it better. We have some kind of scehduled process which keeps hitting our server like every 5 mins with very light 'fetch' requests to keep all servers "hot" (by loading most of the required dlls etc) so that user experience is far better.

I agree it is not a fool proof way but still is something you can consider apart from increasing the recycling settings in IIS.

like image 44
Amit Sharma Avatar answered Nov 18 '22 13:11

Amit Sharma