Entries Tagged 'distributed-computing' ↓

The Architectural Role of Messaging

JMS has brought messaging more into the mainstream which is a good thing. But just like any new technology there is the danger that the first implementations will reflect older paradigms. I remember when I made the move from FORTRAN to C, for a while I wrote a lot of FORTRAN programs in the C language syntax until I got more familiar with C features and idioms. The same goes for my more recent ventures into Ruby with many years of Java thinking under my belt.

Coming back to JMS, I find when I review distributed applications that have been designed by people with a strong client-server or web background I see a lot of rpc message semantics. While rpc (or synchronous request/reply) has it’s place, this is not always the best approach. A common mistake is to regard messaging as simply a way to get messages from point A to point B…treating JMS as a simple transport such as a TCP socket or HTTP.

Messaging originated as the concept of a distributed queue. Most programmers are familiar with queues from GUI frameworks where communications between widgets are mediated via an event queue. The event queue supports a number of functions such as decoupling widgets from each other…allowing each widget to do what it needs to in it’s own time, and supporting event driven interactions between widgets. The event queue along with multi threading is key to giving user interfaces the responsiveness and robustness that you expect. In this way queueing provides more than just a communications mechanism but is key to the architecture of a GUI framework.

The same is true of distributed messaging systems. In their original conception distributed queues do more than just provide a way for data to pass from one system to another, they provide an important element of isolation.

A fundamental difficulty in building distributed systems is that the different components have different performance characteristics. In addition the uptime of your total system is the product of the uptime of individual components. To ensure maximum uptime you want your components to be independent of each other and, in the event of failure you want to be able to restart from where you left off. This is where message queues work really well. Component A puts a message onto a queue and doesn’t  care if or when component B takes that message off the queue. This is known as the fire and forget message pattern and it provides the best isolation between your system components.

If instead we make Component A wait for an acknowledgment from Component B before it proceeds then we are building a tight coupling into the system. Any performance difficulties or failure experienced by Component B could spread back to Component A and thence to other components up the chain.

So the role of messaging in distributed systems goes beyond just getting a message from point A to point B. It also acts as a kind of expansion joint for your system allowing individual components to vary in their performance characteristics - or even fail totally for short periods - without breaking adjacent components.

Without these messaging expansion joints, your system is tightly coupled and prone to system wide failure originating from a single component. Messaging - using the fire and forget pattern - allows these issues to be locally absorbed and managed within normal system operations.

Protocol Buffers cont’d

There’s a pretty heated interesting active discussion going on at Steve Vinoski’s blog re RPC. You know a discussion is going downhill when people start quoting scripture at each other :-)  Here is my comment.

Protocol Buffers: deja yawn

Just catching up on my reading for the last few weeks and I see that Google has open-sourced something called Protocol Buffers. A bit of a yawn really, but interesting from the perspective of adding a new animal into that endless zoo of rpc protocols. Actually, Protocol Buffers are not quite rpc, but actually very reminiscient of XDR which was invented about 12 years ago.

Mark Pilgrim gives a good overview and the comments are interesting to peruse.

Ted Neward writes a really nice discussion of Protocol Buffers (and binary representation in general) versus XML.

Meanwhile, Steve Vinoski begs Google to back off from the “gee we can do rpc with this…” perspective.

Ultimately I ask the question “why do you want yet another binary encoding format”? I think Ted Neward sums it up well:

In the end, if you want an endpoint that is loosely coupled and offers the maximum flexibility, stick with XML, either wrapped in a SOAP envelope or in a RESTful envelope as dictated by the underlying transport (which means HTTP, since REST over anything else has never really been defined clearly by the Restafarians). If you need a binary format, then Protocol Buffers are certainly one answer… but so is ICE, or even CORBA (though this is fast losing its appeal thanks to the slow decline of the players in this space). Don’t lose sight of the technical advantages or disadvantages of each of those solutions just because something has the Google name on it.