Search code examples
iis-7windows-serviceswcfnettcpbindingwcf-hosting

Which is the best option to host a nettcp WCF service


I have a nettcp service which I have to host. I have three options -

  1. IIS 7

  2. Windows Service

  3. A console application

I would be grateful if anybody could give some valuable thoughts on which option is better vis-a-vis other one.


Solution

  • Here are some of my observations:

    IIS 7:

    Pros:

    • Ready made hosting environment inside IIS
    • Will work with pretty much any hosting environment

    Cons:

    • HTTP Only
    • Configuration slightly more complex

    WAS:

    Pros:

    • Ready made and familiar process model to that of IIS
    • No dependency on IIS
    • All protocols supported

    Cons:

    • Not all shared hosting environments will support non-http protocol bindings or unusual port numbers.
    • Configuration slightly more complex

    Windows Service:

    Pros:

    • Starts when windows starts
    • You can start/stop the service via the service control manager
    • All protocols supported

    Cons:

    • Some extra steps to deploy/re-deploy (installutil)
    • You need some extra boilerplate code to support the service implementation
    • Not ideal if you can't have access to the server to install (e.g. shared hosting)

    Console Application:

    Pros:

    • Fast and simple to deploy for testing purposes
    • All protocols supported

    Cons:

    • You need to be logged on to start the process
    • Loss of session or machine shutdown will kill the service
    • Console/RDP access required