Majoring on the Minors

The key to giving good advice is knowing what matters most. It's possible to be 100% correct in what you say and still give stunningly bad advice if your focus is on the minutia of a topic. Rich Turner falls into this trap in his article over on MSDN called "Developing Distributed Services Today". The self-proclaimed goal of the article is to "help you make the best choices when deciding how to build distributed systems today on the Microsoft platform." As such, the article is a miserable failure even though almost all of what it says is accurate. I want to examine what Rich's article leaves unsaid because if you really want to make the best choices about building distributed systems you can safely ignore almost everything in Rich's article, but there are some huge issues that you will have to address.
Distributed Systems
Microsoft has learned a lot about what works and what doesn't in building distributed systems. Unfortunately, the real lessons of the past 10 years don't seem to have permeated throughout the organization. Looking at things from the outside, I would say the BizTalk team and the folks who designed WSE get it, the folks who designed DCOM, .NET Remoting, ASMX, and Indigo (Windows Communication Foundation) don't.
Distributed Objects
They suck. They sucked 10 years ago, they suck today, they'll suck 10 years from now. If you want an accessible platform-independent explanation of why, go read Ted Neward's blog. Here's a bit of advice for architects and developers. If the programming model for your distributed technology of choice includes the concept of a proxy, you're being forced into distributed object semantics. You can build good distributed systems that way, but you'll have ignore all its RAD features and spend a lot of time building your own programming model on top of it.
Services
The key features of services are the messages they understand (i.e. receive and transmit), the operations they perform, and the events they respond to or initiate. Everything is else is just icing on the cake.
Guidance - Building Services Today
My advice assumes you want to build non-trivial distributed applications on Microsoft's platform. Don't worry as much about "future-proofing" applications as you do about actually meeting today's requirements.
Guidance Summary
  • Decide if you need BizTalk Server. BizTalk is a high value and high cost addition to your infrastructure.
  • Use System.Messaging for reliable communication between tiers under your control.
  • Use WSE when MSMQ is not available.
  • Use ASMX web services only as a façade layer.
  • Don't use .NET Remoting.
  • Don't use COM+ and Enterprise Services unless you have to.
  • Design your systems around messages, not objects
  • Prefer asynchronous communication strategies
Build Code Using .NET
Here's the one important thing that Rich gets right.
Build Web Services
The best thing about ASMX web services is that, if you use a little care, you can do simple communication with many platforms. Unfortunately, if you use them the way Microsoft encourages you to (both by their advice and their tool support), you will end up with tightly-coupled applications that use a distributed object paradigm. If you want to integrate with other platforms in any but the most simplistic ways, you really ought to be looking at BizTalk.
Enhance Your Services with WSE If You Need to Support WS-*
Actually, the best thing about WSE is that has a really nice message-oriented programming model and an excellent extensibility mechanism.
Keep Objects and Components Inside Your Services
Great advice. Unfortunately Rich goes on to contradict himself later in the article.
Use Enterprise Services & COM+ When Appropriate
The marriage of .NET and COM+ has been an uneasy one at best. The mismatch between the two systems assumptions (particularly, but not limited to, the difference between garbage collection and ref counting) is so great that complex interactions are typically plagued by nasty bugs. Avoid building systems that require frequent, fine-grained crossing of that border.
Flowing Transactions
Don't use distributed transactions unless you absolutely have to. Avoid designs that allow the caller to initiate transactions. Resources that are that tightly coupled belong on the same system, if at all possible.
Use .NET Remoting When Appropriate
Except that it is never appropriate. Well, it is theoretically possible that it might be the best solution to some problem, but I doubt it. Sure, there are lots of situations where building a system on .NET Remoting won't be a disaster, but why invest in a dead-end technology that won't scale, has no reasonable security story, and forces you into an inappropriate programming model.
Use System.Messaging/MSMQ for Queued Messaging
System.Messaging and MSMQ are Microsoft's most under-utilized technologies. They've done an excellent job steering developers away from it by failing to show the best way to use it. Here's what you need to know:
  • Use private queues. Very few applications need public queues and the performance hit is substantial.
  • Use non-transactional queues. Again, very few applications need transactional queues.
  • System.Messaging is messed up in a lot of ways, but you can work around that.
  • Use the asynchronous methods of System.Messaging (BeginReceive and BeginPeek) where possible.
  • Learn to build your own formatter for System.Messaging.
The Future of Microsoft Distributed Systems Technologies
The future is pretty much irrelevant to building distributed systems today, so I'll ignore the rest of Rich's article.

Posted Aug 04 2005, 07:40 AM by john-cavnar-johnson
Filed under:

Comments

Sam Gentile's Blog wrote The Developing Distributed Services Article Discussion Continues
on 08-04-2005 8:31 AM
Craig wrote re: Majoring on the Minors
on 08-04-2005 10:56 AM
Howdy, virtual neighbor. Have to say, my experience building systems makes me me agree with pretty much everything you've said. About the only point I'd raise is that one of your other virtual neighbors (Don) was one of the designers of Indigo. :o

Luckily, he's highly fire retardant. :)
David Ing wrote re: Majoring on the Minors
on 08-04-2005 12:16 PM
Great post - thanks. Say what you mean next time... :-)

- David
Roman Kiss [MVP] wrote re: Majoring on the Minors
on 08-04-2005 8:52 PM
"Use non-transactional queues. Again, very few applications need transactional queues."

I don't agree with above tip. The transactional messaging in the even driven architecture simplified design pattern and its implementation in the scalable Enterprise solution.

For instance - the web driven application, the request is written into the database and MSMQ in the transactional sync manner and returning back its ticket. Once the ticket has been returned, the request is going to process asynchronously and when it finished, the notification message is sent to the web cluster. The tx-message is ~100x slower than the express message, but the application model doesn't need to cover a multiple sending message across the network, losing messages, crashing process, etc. That's the great benefit of the tx-messaging. Of course, there are applications where can be useful express messages instead of the transactional and the state can be handled in the database, but mostly those implications are deployed in the same machine (there is no possibility to lost or duplicate messages).

Another great feature of the tx-messaging is sending the multiple transactional messages. This “tx-package” can be used for sending large images in the chunking manner, making processing in the specific order, etc.

Also, for the pulling message model such as message balancer, the tx-queues are mandatory elements in this model, without this feature the balancer will not move messages between the request and response queues in the reliable manner.


Roman

Mohair Sam wrote WCF and [DataContract]
on 08-04-2005 10:45 PM
Mike Parsons wrote re: Majoring on the Minors
on 08-05-2005 3:21 AM
Great Post ... when is the industry going to wake up and realize that building Distributed Systems using decade's old OO paradigms is a BIG mistake? Renaming the technology and/or porting it to new languages does not solve the fundamental problems inherent in distributed systems.

I look at Indigo, and while I believe it has some great stuff, decorating a class with attributes to generate proxies is really no different than IDL.

Commonality wrote Developing Distributed Services
on 08-05-2005 5:44 AM
I'm glad someone else brings this to the table. John Cavnar-Johnson puts it very nicely, and I totally agree with...
Marlon Smith wrote re: Majoring on the Minors
on 08-05-2005 7:06 AM
I agree mostly with every thing said...

When I first read the article I understood the intent to be same advice on planning for Indigo.

But you seem to somewhat take offense at his advice and you are also a little rude.

Regarding Indigo and it's programming model, the goal there is to lower the barrier to entry. So in keeping to that theme, what else could be presented to developers other than classes, methods and attributes? XML?

The implementation of the plumbing in Indigo is what makes it so compelling. I try not to get hung up on the fact that I have to communicate with an endpoint through what looks and feels like a proxy.

I have to admit, the attributes do get on my nerves a bit.

Rockford Lhotka wrote “Distributed Objects” are bad?
on 08-05-2005 7:57 AM
Some believe that “distributed objects” are, and always have been, a bad idea
TheChaseMan's Frenetic SoapBox wrote Yet another post on the contract-first aproach
on 08-05-2005 9:17 PM
Udi Dahan - The Software Simplist wrote So you want a distributed architecture, eh?
on 08-07-2005 2:15 PM
<a href="http://pluralsight.com/blogs/johncj/archive/2005/08/04/13855.aspx">John Cavnar-Johnson</a> does a thorough job of demolishing much of the "advice" found on the recent MSDN article by Rich Turner. To tell you the truth, I agree with a lot of what John says. However, both in Rich's article and in John's rebuttal, I find the focus on technology to be over-the-top. The one main point that needs to get drilled home (that John does mention, but not with enough emphasis in my opinion) is that if you've decided on Service Orientation, then you've decided on messaging between your services. Unless a message is a Query Message (something like GetCustomers - level=platinum AND join date=last month AND last purchase date < last week), then these message interactions should be asynchronous.
<BR/><BR/>
For anyone whose ever done this sort of thing, the technology for transporting messages between services is probably not an architectural issue. I have yet to see a single detailed design document online that shows how to design a service that will support asynchronous message exchanges. Everybody's going on and on about which technology to use - System.Messaging, Indigo/WCF/WTF/Whatever, Remoting, ASMX, ... like that's really going to break the bank. Without a solid design, how could such technological decisions even be made?
<BR/><BR/>
Here's a short description of such a design...
XML Nation wrote On messaging and distributed system design
on 08-08-2005 2:24 PM
XML Nation wrote On messaging and distributed system design
on 08-09-2005 9:46 AM
Commonality wrote Get To know thy BizTalk
on 08-10-2005 7:37 PM
Recently, some prominent people have started (or, most likely, are just now talking about it) about BizTalk Server, some in...
Steve Swartz wrote re: Majoring on the Minors
on 08-12-2005 10:05 AM
Do you know that WCF is the programming model for MSMQ (and, outside the database, for SSB) moving forward?
rogerv wrote Tibco EMS
on 08-23-2005 12:05 AM
For a couple of years I've been using Tibco EMS (Enterprise Messaging Service), which is a heterogeneous implementation of JMS. Tibco has excellent client support for .NET Framework, .NET Compact Framework (very handy for embedded WinCE messaging nodes), C/C++, and of course Java.

I build .NET clients and use J2EE in the middle-tier where messages are processed by the message driven bean (MDB) EJB type. I also use JMX mbeans for controlling serial devices but that clients communicate to via high level JMS messaging.

I message XML documents described by XSD. On the .NET side I use the XsdObjectGen tool and on the Java side I use JAXB. Both tools generate source code for marshaling/unmarshaling XML documents.

In the J2EE environment I use Hibernate to directly persist object graphs that result from JAXB unmarshaling XML messages. Persistence and messaging are usually done under an XA transaction. When there's a failure, then after a specified number of retries, the message is moved to a dead letter queue which is monitored for raising alerts - just as is the J2EE error logging.

Tibco has high availability clustering and its server component is written in C code - a single server can handle thousands of connections. You'll find Tibco EMS messaging the best that can be had to use on Windows / .NET programming platforms.
John Cavnar-Johnson wrote re: Majoring on the Minors
on 08-23-2005 5:33 AM
It's been a few years since I was forced to use TIBCO products, but I must say my experience was very different from yours. I found their products to be overpriced, idiosyncratic, and unmanageable. From what little I know of JMS I would expect it to be a far superior API to the ones TIBCO exposed 5 years ago. I think I'll stick with MSMQ, but that's a personal preference. Your mileage may indeed vary.
rogerv wrote Tibco EMS is not Tibco Rendezvous
on 08-23-2005 7:19 AM
Tibco EMS is a straightforward implementation of the JMS spec. It is not the same thing as their Tibco Rendezvous product that has been used pervasively on Wall Street for stock transactions. So Tibco has a mix of messaging products for different kinds of markets. (One of the more interesting is UDP-based Smartsockets - which might be a good match for some wireless distributed applications.)

Am a former Microsofty and have used MSMQ - it's not in the same league as contemporary JMS products of the likes of SonicMQ and Tibco EMS.

Even when looking past its lackluster messaging semantics (relative to JMS), MSMQ is a non starter in many enterprise IT development shops because its heterogeneous integration story is abysmal (compared to said JMS products).

I would say this for MSMQ, though: If faced with doing a distributed project with DCOM or .NET Remoting vs MSMQ - I'd take MSMQ in a heartbeat. I'd take practically any messaging solution vs RPC when it comes to distributed application architecture.
On the road to Indigo wrote In response ... Dear John
on 09-06-2005 1:51 PM
Dear John.
Thank you so very much for taking the time to read the whitepaper I recently published to...
Dennis van der Stelt wrote re: Majoring on the Minors
on 09-06-2005 10:46 PM
Man, I love these fights! ;)

But why doesn't your template/skin show the trackback link to the sites that created the trackback? That sucks!
John Cavnar-Johnson wrote re: Majoring on the Minors
on 09-07-2005 5:08 AM
Dennis,

I'm glad I can provide a little cheap entertainment in these troubled times. I agree about the trackbacks, but all the trackback spam is even worse. I do my best to hoist the relevant links back into my posts.
Stefan Tilkov's Random Stuff wrote Messaging vs. RPC
on 09-11-2005 11:51 AM
Nothing like a nice pissing contest: Rich Turner and John Cavnar-Johnson go back and forth about how to do distributed programming the right way. The starting point was Rich&#8217;s whitepaper on Developing Distributed Services Today, to which John posted a somewhat less than favorable comment. Rich responded (a little childishly, IMO, even in the edited version); John followed up again....
Nancy, web design coordinator wrote re: Majoring on the Minors
on 10-25-2005 8:04 AM
I think you advice quite reasonable things. It's really important to share our experience with others in a kind of discussion so that we all would benefit. I have saved your post for our developers and they learnt some new things from it. The only questionable thing was "when appropriate". Have you posted any more detailed arcticles?
ros wrote re: Majoring on the Minors
on 07-17-2006 12:39 AM
how to obtain a singleton architecture, without using .NET Remoting

Add a Comment

(required)  
(optional)
(required)  
Remember Me?