tags:

views:

91

answers:

3

I have an WCF site on IIS 7. The site is rarely being accessed which causes the application to unload. How can I keep the application (WCF) up all the time?

A: 

There are a couple of options.

  1. As noted in the comment by marc_s, you could host the site in a Windows Service or even an application
  2. Create a keep-alive request that pings your site with a request on a frequent basis.

Lastly, under .NET Framework 4.0 you have the option to keep apps alive indefinitely. I doubt you are on 4.0 yet, but it's one thing to consider.

Nissan Fan
The .NET 4.0 suggestion sounds very interesting as a future option, could you give me a reference?
Eran Betzalel
Here: http://weblogs.asp.net/scottgu/archive/2009/09/15/auto-start-asp-net-applications-vs-2010-and-net-4-0-series.aspx
Nissan Fan
A: 

Host it in a Windows Service, instead of depending on IIS (as marc_s and Nissan Fan state).

http://msdn.microsoft.com/en-us/library/ms733069.aspx

Nicolas Webb
+5  A: 

There's no reason to stop using IIS. All you need to do is set the application pool options so that the service is never shutdown due to inactivity. Unfortunately the defaults are something like 20 minutes of inactivity and every 29hrs regardless.

What I would suggest is:

  1. Create a new application pool just for your service.
  2. Once created, right click on it and choose "Advanced Settings..."
  3. Look for the "Idle Time-out (minutes)" setting under the "Processor Model" group. Change this setting to 0 to have the service never shut down due to idling.
  4. Consider changing the "Regular Time Interval (minutes)" setting under the "Recycling" group as well if you do not want the process to be recycled. You can either set this to some number of minutes (as I said it's 29hrs by default) or you can set this to 0 and instead configure the "Specific Times" setting so that your service is recycled at optimum times of the day (say, 4AM or something). If you run a web farm you would configure the farm to recycle in a staggered way so that at any given time only one server is recycling.

Fun trivia: the reason the default recycling is 29hrs is because this will cause a recycling every day, but 5hrs later each day so that the time of day is never the same.

For more on configuring application pools, check out this section on TechNet titled Managing Application Pools which covers the topics I've mentioned above as well as many others.

Drew Marsh
Thank you very much, that's exactly what I needed.
Eran Betzalel