Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should we host WCF service in IIS and when should we host in a windows service?

I need to host my WCF service but I am unable to decide whether I should host it in IIS or a windows service?

What are the advantages, drawbacks, benefits of one over the other please?

Thank you

like image 997
InfoLearner Avatar asked Sep 26 '11 16:09

InfoLearner


2 Answers

IIS under version 7 is out of the question for any serious hosting anyway....

As for IIS7+/WAS vs. self-hosting in a NT service:

  • the IIS7/WAS setup will "load on demand", e.g. when your first request comes in, a ServiceHost will be created, then that service host creates the service class to handle the request. This is beneficial from a memory point of view (uses no memory for the ServiceHost if no requests come in), but it's a bit of an additional overhead on the first call when IIS first needs to spin up the service host

  • NT Service allows you to pre-create the ServiceHost and open it so it's ready to handle requests right away; a bit more memory usage, but a bit more responsive, at least on "first calls"

Another benefit of self-hosting: you're 100% in charge of when the service host starts, pauses, stops, and so on. With IIS/WAS, you're at times at the mercy of IIS with its potential to recycle app pools at the worst possible moment......

like image 145
marc_s Avatar answered Oct 23 '22 03:10

marc_s


The main advantages of IIS is that it handles the lifetime of your service for you: activation, recycling...

Its main drawback if you don't have v7 is that without WAS it can only host http based web services

The services need more care in case of fatal error... and then need to be installed whereas a web site can be copied to its web folder once it has been created

If your version of iis is >= 7, then I don't see a lot of interest in not using WAS as it supports all the wcf transports, others might have a different view though...

like image 30
vc 74 Avatar answered Oct 23 '22 03:10

vc 74