Every distributed program is generally hosted in one environment. It is very important to host the service in the best possible location or environment. WCF is very rich in hosting because it offers different types of hosting.
There are five different ways you can host the WCF Service. Those are IIS 5/6 Hosting, Self Hosting, WAS Hosting, Custom Hosting in IIS/WAS, Windows Server AppFabric.
IIS 5/6 Hosting:
Like normal Web Application or Web Service we can host the WCF service on IIS 5/6 . The main advantage of hosting WCF service on IIS is you no need to start the WCF service manually, WCF service automatically start on client first request. But you can host WCF service on IIS through HTTP/HTTPS protocol only because IIS supports only HTTP/HTTPS protocol only.
By hosting the WCF service on IIS client can access the WCF service like a Web Service only but instead of .asmx service client will call .svc extension.
Self Hosting is the most simplest hosting for WCF service and less important one. We generally use the Self Hosting for WCF service when developer only has to control the WCF host process. Use Self Hosting when you want to use same process for WCF service and its clients. We use the .Net Windows Applications, Console Applications, Windows Service or WPF applications as Self Hosting for WCF service.
When we host the WCF service by using IIS, it host our service like Web Application because IIS is a Web Server not a hosting engine. So when you host WCF Service on IIS, Asp.Net runtime will execute the Service, WCF service has to go through many HTTP Modules and the Asp.Net pipeline. Because of this execution time and complexity of WCF service increases.
Microsoft introduced the next generation hosting engine called WAS(Windows Activation Service) on Windows Vista, Windows Server 2008, Windows 7(and latest) to host the Service as a service not like Web Application. Through WAS you can host Web Sites also, IIS 7 hosts its web sites by default in WAS. WAS supports many protocol like TCP, IPC and MSMQ. WAS provides many advantages over Self Hosting also like application pooling, recycling, idle time management and isolate the host process.
Custom Hosting in IIS/WAS:
Sometimes you need to interact with the host instance, generally when you use the IIS or WAS hosting you cannot access host instance. To access the host instance WCF provides hook called "host factory". By using the Factory tag in .svc file you can access the host instance.
Windows Server AppFabric:
WAS is a normal hosting engine, it does not know whether it is hosting for WCF service or a website. Because of this WAS is not optimized for hosting the services. To solve this issue, you can install WAS extension Windows Server AppFabric. Windows Server AppFabric requires IIS 7.5 and it has to run on Windows 7 or Windows Server 2008 R2 and also requires .Net 4.0. Windows Server AppFabric can track both WCF and WF(Workflow) services.