How to keep a WCF site online?

2020-07-10 09:43发布

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?

标签: wcf iis
3条回答
欢心
2楼-- · 2020-07-10 10:06

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.

查看更多
\"骚年 ilove
3楼-- · 2020-07-10 10:09

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.

查看更多
淡お忘
4楼-- · 2020-07-10 10:13

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

查看更多
登录 后发表回答