I have a simple and direct question: is there any performance benefits (or any other type of benefit) I am unaware of when comparing hosting of a WCF service in IIS 7.5 vs. a Windows Service?
I am not in the dark on this topic and have actually hosted several WCF services in both hosting environments. However I was about to start a new service that has some heavier use and wanted to 're-visit' the topic. Right now I am leaning twoard a Windows Service.
I have read posts like the following: IIS WCF service hosting vs Windows Service which gives some good information, but is a bit out of date (yes even only at 1.5 years old; still using codename 'Dublin Technologies').
There is no ding against Windows Services for me because I am quite comfortable with setup, deployment, and configuration (including applying an SSL cert to a port hosting the WCF service), so this is not a big deal to me vs. IIS.
I always thought application recycling in IIS would be a downside to hosting a WCF service, allowing potential for small possible breaks in communication. I know with a .asmx IIS hosted service (converting to WCF) that I have receives random '401 Unauthorized' (I mean really random like every 5-10,000 calls kind of thing) and I marked that up to idiosyncrasies with IIS and its ability to keep communication up 100% of the time without the app pool being recycled (possibly causing issue? -> this issue is not in question here and just for reference). So I wonder about IIS.
So I would like a current day's perspective (a lot of the MSDN comparison charts are out of date too, always comparing to IIS 6) on hosting a WCF service on Windows Server 2008 R2 in a Windows Service vs. IIS 7.5. Thanks!!
WAS Hosting − Hosting a WCF service in Windows Activation Service (WAS) is most advantageous because of its features such as process recycling, idle time management, common configuration system, and support for HTTP, TCP, etc.
In short, you can't. A more detailed answer is that there are 2 problems: IIS worker processes are launched only when a HTTP request comes in. This means you can't start your service with the system.
With the release of AppFabric for IIS, hosting WCF services on IIS 7.5 have gotten a bit easier and more reliable. AppFabric allows you to configure services to start up on application pool start and prevent the pool from recycling like a normal web application. It also provides methods to allow your WCF service to log information about its health and monitor the service.
For my most recent WCF project, I've gone with ASP.Net 4 and AppFabric with .svc extensions for hosting the code. (Currently, AppFabric has issues monitoring services that are routed - so an .svc file is required)
Here are a couple more useful links about WCF and AppFabric:
Another advantage I've seen in the IIS method is it allows you to create pages next to it to help monitor, maintain, and configure the services. With a Windows Service you have to either edit your config files by hand or create an application to handle it for you. The ability to host WCF next to WebForms/MVC applications for management is a huge plus in my book. Obviously, you'd need to make sure it's secured in some way to prevent others from peering in and seeing the status/configuring it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With