views:

18

answers:

2

I'd like to host a WCF service in IIS 7. I'm not familiar with this topic, but a coworker ensured me that IIS is going to shut down the hosted service after some time ("days") no matter what.

When does IIS actually shut down my services automatically? How do I set it up so it keeps them running all the time (even if they are not doing any actual work)?

+2  A: 

IIS may unload a service's AppDomain at any time to save memory.

If a request comes in on the service's endpoint(s), IIS will re-load the service, and the request will be handled normally.

As far as the service is concerned, this is no different from the server re-booting.

This will only be an issue if your service needs to run (not just listen) continually in order to perform some kind of background processing.
If so, you should write a normal Windows service and not use IIS.

SLaks
+1  A: 

A webservice in IIS is hosted as an application owning an application-pool. Normally these pools are setted to recycle themself in regular intervals - like this your service would be restarted.

In the application-pool settings (inside the inetmgr-console) it is possible to deactivate these recycles (under "advanced settings" -> "recycle configuration").

About failure-recovery there exists possibilities to configure them also in these settings but I'm not sure if they really do what you expect them to do.

Finally I would suggest you just to host your services by a hoster-application outside of an IIS as a system-service which can then be configured to automatically restart and also create a log entry. Normally a WCF-Service is not designed to be alive longer than the request takes. In one of our projects we exactly did this after recognizing the problems with IIS and it made our work easier...

Olaf Watteroth