InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

How Big Should A Service Be?

Posted by Mark Little on Aug 08, 2007

Sections
Enterprise Architecture
Topics
SOA Platforms ,
SOA Appliance ,
SOA
Tags
SOA Adoption
We often hear the discussion about how large services should be in a SOA deployment. But the arguments about the coarse-grained versus fine-grained have raged for many years in other, more traditional architectural approaches, i.e., this is not something that is specific to SOA. It's also an example of where one size does not fit all: sometimes size really does matter! A recent report adds further fuel to the fire around this often heated debate:
A Service is not simply an object exposed with a standards-based API or just another way of doing object-oriented programming “in the large”. Indeed, just as object orientation offers a different level of abstraction and thought from procedural programming, Service orientation offers a different level of abstraction and thought from object-oriented development.
The report goes on to add:
Indeed, the Service-oriented movement is not a technology one at all! It is a business-oriented movement where the abstractions are the very abstractions that relate to how a business considers the ever-changing and continuously heterogeneous aspects of its organization and how they can be composed in a loosely-coupled manner to allow for flat and predictable cost of change. This means that we have to rethink the way in which we approach IT capabilities, not simply expose the same assets in the same way using a new interface or middleware.
As with other discussions around this topic over the past few years, the report highlights the challenges around service granularity, defining a fine grained service to be one that "addresses a relatively small unit of functionality or exchanges a small amount of data", whereas a coarse grained service is one that abstracts larger chunks of capability within a single interaction. Others have shown how deciding on the granularity of your service is a critical aspect of the service lifecycle because it impacts the composability of loosely-coupled services as well as the reusability of individual services.

The report goes on to discuss the top-down and bottom-up approach to developing services (both are required to one degree or another):
... starting from the business-process or a business model and decomposing that into sub-processes or sub-models recursively until some condition is met by which it can’t be decomposed any further. Alternatively, an architect can start from the IT systems already implemented, expose Service interfaces from the APIs and access points that already exist, create Service Contracts on top of those interfaces, and then compose them together until the business process requirements are met.
Whether you are developing composite services or atomic services also has an impact on the granularity of your services:
While at first blush it might seem that all atomic Services are fine-grained and composite Services coarse-grained, this is not necessarily the case. Since granularity is a measure of interaction and business appropriateness, and atomicity is a measure of process decomposition, it is quite possible to have coarse-grained atomic Services and fine-grained composite Services.
Finally the report produces a granularity matrix, which shows the trade-offs between service granularity and atomicity. The conclusions are probably well know to most people who have tried to develop services over the years:
... a proper Service-oriented analysis and design approach considers separately the issues of granularity and atomicity with respect to five key aspects: reusability, efficiency, transactionality, consumability, and visibility of the Service. What might at first seem to be a composite Service from the perspective of reusability might actually need to become atomic due to reasons of transactionality. Likewise, what might seem to be fine-grained for the purposes of visibility and auditing might become coarse-grained for reasons of efficiency. Indeed, the Service granularity matrix serves as just another tool in the belt of the effective enterprise architect.
So does size matter? Yes, but sometimes big isn't necessarily best. Furthermore, because one coarse grained service may work well in a particular environment does not necessarily mean it's best suited elsewhere. Services evolve with the applications that use them.
  • This article is part of a featured topic series on SOA
performance and re-use by Gerald Loeffler Posted
  1. Back to top

    performance and re-use

    by Gerald Loeffler

    (i'm a bit late to comment on this entry but i don't have much to say so it doesn't really matter.)

    this granularity discussion reminds me of a nice remark that Gregor Hohpe made in a recent presentation (which are btw flooding the internet, aren't they ;-), namely something along the lines that "if your services are too fine-grained then you get bad performance and if your services are too coarse-grained they don't get re-used". i would agree that performance and re-use (for service composition) are the two most important dimensions along which service granularity should be assessed.

    one a more cynical note:

    just as object orientation offers a different level of abstraction and thought from procedural programming, Service orientation offers a different level of abstraction and thought from object-oriented development.

    exactly: that of procedural programming - it's a regressive movement!

    cheers,
    gerald

    www.gerald-loeffler.net

Educational Content

Jesper Boeg on Priming Kanban

In this interview, Jesper Boeg, author of the new InfoQ book – Priming Kanban, discusses the keys to using Kanban effectively, and how to get started if you are currently using other approaches.

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.