06 March, 2008

WCF Durable Services

The advent of .Net 3.5 has made two of its core tenets: WCF and WF interact with each other and interdependent to a certain extent. One notable product of this association is WCF Durable Services.

What is it?
A Durable Service (new in WCF 3.5) is an implementation of a long running WF service, which persists the state of the service and its message contents on a per client basis. The state can be persisted "out-of-process" and the client can resume the execution at the last saved point.
The persisting and depersisting activities (also called dehydrating and rehydrating) are done immediately prior to and after a service method is called. The persistence store is fully configurable (via config file) and could be SQL Server, file system or any custom store.
A Durable Service inherently supports durability and reliability.

Why is it required?
The most apt use of a Durable Service would be in business scenarios with heavy data dependent tasks that require per-client persistence and high reliability. One such candidate might be a large file transfer system, where the file is split into multiple smaller chunks and transferred between client and server. If client loses a session or a chunk, Durable Services would enable the client to resume the download / upload activity without having to redo the entire file transfer activity again.

Bucking the trend?
The general design of a typical service (say web service) is to perform the requested operation and terminate the state of the service immediately. It was always considered a bad practice to persist the state of the service itself. However, Durable Services (are intended to) persist the bare minimum data with which the client can resume the activity.

Pros and Cons
The main advantages of Durable Services are persistence and reliability.
One obvious disadvantage is the performance overhead brought about by the persistence activities in each call.

References
1) Mike Taulty's informative screencast.
2) Jesus Rodriquez's crisp
weblog.
3) Udi Dahan's
podcast of Durable Services with WCF, WF and NServiceBus.
4) MSDN's calculator
example.
5) I have explored Durable Services to a good depth as part of my work assignments. I have implemented a large file (2 GB or more) download system with Durable Servies (WS-Http-Binding and SQL Express).

No comments: