Beyond operating platform and choice of protocol, other features available to the hosting environment also influence deployment decisions and choice of host. This article describes the desired features of a hosting environment; provides you with an overview of WCF hosting options and their availability; and explains how to implement scenarios applicable to each environment.
WCF is part of the .NET Framework 3.0 stack and thus is supported on the following operating platforms: Windows XP/SP2, Windows Vista, Windows Server 2003, and Windows "Longhorn" Server. Regardless of platform, you can access WCF services over many protocols including HTTP, TCP, IPC and MSMQ. Unfortunately, not all hosting environments are available to each platform, nor does every host support the entire suite of protocols—limiting your options at times.
Features of a Great Host
Hosting environments make it possible to expose your services to client applications. They facilitate request processing to service operations, but they can also play a critical role in the availability and scalability of your services. A great hosting environment should provide these important features:
* Executable Process/Application Domain: You can use any managed process to host WCF services, which implies the existence of an application domain ("app domain").
* Configuration: A mechanism for external configuration should be available to support deployment and manageability. For managed hosts this is supplied by the application configuration file (app.config or web.config).
* Activation: Ultimately the service model instantiates the appropriate service type to handle incoming requests, but the host process must initialize the channel stack that receives incoming messages. You can do this activation at host startup but it is preferably done through message-based activation.
"Self-hosting is the simplest way to host your services-and the approach that yields the least number of hosting features."
* Idle-Time Management: To conserve server resources during idle time, hosts can release unused resources. Hosts that support this feature usually provide a configurable timeout. Idle-time management relies on the activation capabilities of the host to instantiate resources as needed.
* Health Monitoring: To ensure availability a host process must always be running to service requests. Some hosting environments can proactively monitor their processes to ensure a new host process is started when existing processes are unable to service requests.
* Process Recycling: To avoid problems associated with memory leaks or faulty code, some hosting environments support configurable process recycling to "freshen up" running host processes.
* Management Tools: Sophisticated hosting environments also provide tools for configuring hosting features for greater control and manageability. This toolset sometimes contains tools for monitoring the health and status of running host processes.
There are three types of hosting environments for WCF services: IIS, WAS, and self-hosting. The term "self-hosting" refers to any application that provides its own code to initialize the hosting environment. This includes console, Windows Forms, WPF, and managed Windows services. Table 1 provides a summary of these three hosting environments and the features they support.
Table 1: A summary of hosting options and supported features.
At a minimum, all WCF hosts provide an executable process and application domain in which services are loaded. They also provide support for external configuration. The remaining hosting features discussed here are built into IIS and WAS, but not provided by self-hosting environments. Despite this fact, self-hosting does have its value under the right circumstances.
In the sections to follow, I'll discuss how the service model exposes WCF services, and then I'll describe scenarios for self-hosting, IIS, and WAS.
No comments:
Post a Comment