Friday, April 23, 2010

Best Practices for WCF

The general best practice for WCF services would be to have the per-call, single-instance model whenever possible. This gives you the best throughput, the best and simplest behavior in the service instance. So whenever possible, and unless you have a really compelling reason, use this model. Always try to make the actual service instance very lean and lightweight so it can be created and disposed of in a blink of an eye (or less), and then have some background worker processes which you can then call from your actual service instances.
 
But of lately SOA has been a buzz word. That's been a big question surrounding services since their inception. SOA done successfully is SOA planned to the extent you're talking about. Having said that, I've always leaned more toward splitting services out, but using them in a composite manner. That is, several endpoints when you have several contracts, but most of them are only consumed by a few endpoints that are consumed by non-service callers.

Also, I would advise to have as few contracts as possible. Too many contracts can lead to poor manageability. Good contract design will help limit the number of endpoints and service calls. Removing OO concepts from contract design is one way of doing so. Contract design is a massive topic in itself, but suffice it to say that through good contract planning (up front), comes good service design.

Maarten Mullender writes a great blog on WCF design, and is a must read. There are also some great SOA/WCF books emerging as well. Some good books:

This has been helpful to me it comes from the idesign.net website and it was authored by Juval Lowy: WCF Coding Standard

For more comprehensive details refer to MSDN: Guidelines and Best Practices in WCF.
Also for security point of view refer to MSDN: Best Practives for Security in WCF.

Do keep sharing any new updates in this regard.

4 comments:

Comments to this post

LinkWithin

Related Posts with Thumbnails