简体   繁体   中英

Hosting WCF in IIS 7.5 vs Windows Service for Performance Considerations

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!!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM