Tuesday, February 20, 2007

Essence of Service Oriented Architecture

You have long known that web services can be used to build Service Oriented Architecture, so lets discuss something more about it (Please note again, web services are means to achieve Services Orientation. You don't get a Service Oriented system by just employing them).

There is a web service in Microsoft CRM that provides the method Create() to you. It inserts a record at a time in CRM system. Recently I had to upload the data to one of the tables of MS CRM using this web service. You know it is damn easy to write a web service in .Net world, so I got my collection of data, hooked to this web service and started inserting 41K records into MS CRM system. What do you think how long it would have taken? It took me near about 3 hours to insert 41K records as against my local Dev machine where it took 15 minutes. 15 minutes sound good, right? Right.

Then why did it take so long when I tried the same thing with live machine? I have mentioned the problems in following post:

Motivation behind Service Orientation

foreach(User user in userCollection)
{
      Process user
 }

Here is the problem. What if the collection you are processing is sitting miles away from you? You get all latency possible under the sun. Though you are using "web services" your system is no more service oriented. The same happened with me. Though I have collection I am processing with me but I don't have service sitting next to me. See the situation. I am going to call this service 41K times. Then this service internally create 41K connection to underlying data source (yeah yeah yeah, SQL server provides connection pooling so it wouldn't cost me that much). But you see I am violating the essence of service orientation, where web services should not be chatty. It should not be "Hi, Hello" type. They should do the real business in each call.

How this could have been Service Oriented? Well I have my collection of data. I supposed there should be a service ready to expect any kind of mass data from me and then process it accordingly. This way I would have saved 41K trips to server. It is not chatty any more now. All latency I would gotten is the time to transfer the payload to server. Then data becomes local and service becomes local. It becomes much more sensible. This is the real business value.

After all Service Orientation is about bringing value to business.

Service Orientation is about bringing value to business