Saturday, February 27, 2010

Selecting appropriate WCF binding for your application.

WFC comes with multiple bindings out of the box, allowing us to customize each one of them.

It also allows us to create Custom Bindings (using Windows SDK) and User-Defined Bindings (a custom class inherited form the Binding class that performs all steps needed to create bindings)

Here I intend to discuss the basic bindings that come out of the box. We will not be going in details of each bindings but will discuss enough to decide which binding to use.

Understand WFC Bindings’ naming convention:

Here’s how the name of the binding gives information about it:

  • The bindings that start with net* are meant to be used between .NET applications.
  • The bindings the include *http* are obviously meant to be used with web services hosted on IIS using port 80 for http and port 443 for https.
  • The bindings that start with ws* follow the WS-* specifications (pronounced as WS star). These should be used for interoperability using web services.
  • The bindings that include *Msmq*should be used for communication through queues using Microsoft Message Queues (MSMQ).

A quick look at the out of the box bindings offered by WCF:

  • netNamedPipebindings binh ding is restricted to to local machine communication. It is great for inter process communication (IPC).
  • netTCPBinding should be used for cross-machine communication between two .NET applications.
  • basicHttpBindings supports web service communication and offers interoperability across heterogeneous systems. It follows WS-BP 1.1 standards and can be used for application like ASMX Web Service. However they do not provide latest web service standards such transaction management and message reliability.
  • wsHttpBinding includes all that is in basicHttpBinding along with advance infrastructure level protocols such as security, message reliability and transaction management. This is the default binding in .NET Framework 3.0 whenever web service based communication is required.
  • ws2007HttpBinding include all that is in wsHttpBinding along with the latest WS-* standards available for security, message reliability and transaction management. This was introduced in .NET Framework 3.5.
  • The netMsmqBinding is used when you are creating new application where as netMsmqIntigrationBinding is used for interoperability with an existing application. Both support message queuing with disconnected application (where client an function whether the server is available or not).

Comparing Binding Performance and scalability:

I have picked up the following flow chart and  comparison data from Essentials Widows Communication Foundation by Steve Resnick, Richard Crane and Chris Bowen. I also consider it a good read for understanding WCF from basics.

The flow chart is quite self explanatory guiding us to a particular binding:

Selecting a WCF Binding

The Graph below compares the performance showing the average response time of each Binding:

Average Response Time 

Finally the graph below shows the average number of operations per second for each binding which is one measurement to determine scalability:

Operations Per Second

No comments:

Post a Comment