简体   繁体   中英

is it a good practise to self host wcf service in production

I am creating a WCF service, I would like to self host it in production,Is this possible ? and if possible is it a good practice, And i did searched the web and i found a lot of explanations but not a reference about self hosting service in production.Please give your suggestions.

Each type of hosting is suited to particular business requirements. Here is an example of when to use self-hosting services from Programming WCF Services by Juval Lowy :

Use self-hosting when you want a process (or machine) boundary between the client and the service and when you are using the service in-proc—that is, in the same process as the client.

Simple answer is: No, it is not a good practice. But it doesn't mean, that there is no any scenario where you could use it, especially in some not sophisticated situations. Remember to Keep It Simple Stupid (KISS). Don't introduce complecity into your solution.

Here is an another example when you might to use SH from Pro WCF 4 Practical Microsoft SOA Implementation SECOND EDITION by Nishith Pathak :

You also might want to selfhost your services when you want applications on a user desktop to communicate with each other, or in peer-to-peer scenarios

Those are the exceptions from the rule, I think. In other cases don't use SH, unless you have a significant reason which you could defend.

While possilbe to do self hosting, it is often much easier to use a host (such as IIS) since a lot of work and thought are put into its implementation, resulting in a robust and scalable hosting solution.

"Production" does not say much - if you have no window servers and a small amount of clients, and availability is no big issue, then self hosting can be a simple, fats, good enough solution.

It's technically possible (depending mainly of the load of the server and features needed) but IMHO it's far better to use IIS, which is more reliable, monitorable, and optimized in many ways.

Example : if your self hosted service's process crashes, you restart it manually ? You write a daemon just for that ? IIS handles (of course) this.

For small needs and if you don't want to use IIS, it's still possible to use self hosting but I don't see any real advantage to use SH rather than IIS.

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