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

人走茶凉 提交于 2020-01-16 05:34:48

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/26710909/is-it-a-good-practise-to-self-host-wcf-service-in-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!