Thursday Apr 21, 2005

SOA - Coarse Grained vs Fine Grained Services Service granularity is a recurring hot discussion in design teams. So, I am glad that my amigo John Crupi started this discussion on SOA Granularity. The issue of granularity is a never ending discussion, and as John mentions is an easy way to start a debate. The issue of granularity is not just an issue in SOA. We have always had to deal with object/procedure/service <insert-your-favorite-here> granularity in designing a system. I think SOA magnifies the granularity issue by bringing it to the forefront of the design discussion.

IMO, granularity is a subjective matter. What is coarse-grained for one is not coarse-grained for another. I think this subjectivity is one of the reasons that granularity becomes a hot topic debate amongst designers. While granularity is one aspect that must be paid close attention to, I think it is better not to issue edicts around it. Because the moment you define a law of granularity, someone is going to break it! Trust me.

Pragmatically speaking, a (composite) SOA application will contain services of varying levels of granularity as shown in the diagram. I think what John is pointing out is that you want to ensure that the services that are exposed externally are the ones that are on the top (i.e. relatively coarse-grained). Anyway, I do agree with John that when talking about SOA services, we should be talking about business services. But, that does not really imply that we should always make a service coarse-grained. So, can a business service be fine-grained? It depends, on the business it serves.

For instance, let's say you are a famous online auction company and many successful small business partners use/depend on your auction platform. Let's say that these users require a service to be exposed that returns the latest bid price for a given item number. Is this too fine-grained? It sure feels like it when compared to other services like Create AuctionEnd Auction, etc. But what if this is indeed business speak. That is, your business managers want to provide a Latest Bid Price service. And what if your partners using this service are willing to pay for it. Will you not expose this service because it is fine-grained? Hell, no! You are going to expose that service. Why? Because it is going to make money! Whether that be a Dime, a Rupee, a Yen or a Yuan. (OK, it is not always about money, but surely about generating some business value.)

So while we lean towards making SOA services as coarse-grained as necessary, remember that whether a service is coarse-grained or fine-grained or in between, if it makes business sense, it must be a good service to expose to the world.

 

YouRIt

This blog copyright 2007 by alur