hosted WCF services limited in any way?

Are there any limitations (performance, memory, threading, etc.) in self-hosting a WCF service within a Windows service... instead of using IIS? There are tons of articles showing HOW to do this but very few discussing IF you should do this. A rather complex app I've built requires me to self-host a WCF service for peer-to-peer communication. It is very tempting to use the same self-hosted pattern on the server for the "master" services that global users must hit.


The main points to consider are:

  • Port Sharing: IIS gives you port sharing for free. To use port sharing in a self hosted environment you need to handle this yourself
  • Limited availability: The service is reachable only when the application is running.
  • Limited features: Self-hosted applications have limited support for high availability, easy manageability, robustness, recoverability, versioning, and deployment scenarios. At least, out-of-the-box WCF doesn't provide these, so in a self-hosted scenario you have to implement these features yourself; IIS, for example, comes with several of these features by default.
  • Take a look at the MSDN docs for an overview on the trade offs you need to consider.


    I helped architect two systems that utilize self-hosting for WCF and it works very well (we used NetTCP for the underlying communication protocol). It was mostly a proof of concept to see if I could do it and it ended up working really well, though there are some performance things to consider. First, depending on the number of services your memory footprint can get a little large - the one I architected had ~40 individual services, but then the support team who took over kept adding new ones and it went to 92 last I heard. That starts to introduce some slow startup times unless you thread the initialization process since opening each one under its own AppDomain (something you'll definitely want to do) has some additional overhead. I can't speak to whether the performance is better/worse than IIS hosting, but overall, it definitely works well - just be prepared to learn a decent amount about background threading and AppDomains as part of the process.

    链接地址: http://www.djcxy.com/p/54938.html

    上一篇: 从另一个WCF服务中调用WCF服务时发生WCF内存泄漏

    下一篇: 托管的WCF服务以任何方式受限?