
Dan Pritchett follows his first post with more thoughts about living in a world free from 2pc commit:
- The only way out is through.
- A call to order is in order.
- It’s better to be an orphan than an empty nester.
- Better late than never.
- Idempotent operations are your friend.
So 2PC or not 2PC?
Dan lists the common techniques for building reliable and scalable applications. Depending on your application logic, you’re looking at order of operations, idempotence, asynchronous processing, compensation, etc.
All these techniques work like the color palette of a painter. Which colors you pick, how you mix them together, where you draw them on the canvas depends on the image you’re painting.
During the development process, you’re making these decisions as you’re building up the application.
But during the initial design phase, such answers may easily fall on deaf ears. You’re thinking high-level without getting deep in the details of each functional unit. The sound of hammers is more pleasing.
You say “we’re going to trust our skills and apply the right tool,” and someone else hears “we’re going to slip the schedule while we’re re-inventing the wheel”. When you’re looking for a definite answer, 2PC has more to offer.
On paper.
You still need to worry about order of operations to prevent deadlocks. You still have to deal with idempotency in user-facing interactions. You still need asynchronous processing for longer tasks. You still need to consider compensation. All too often, 2PC just buys you the illusion of simplicity.
And it brings its own operational baggage. Dealing with deadlocks, hanging transactions and heuristic outcomes is notoriously hard.
The majority of business transactions are performed with limited or no 2PC for a reason. And with the proliferation of services, we’re going to see that pattern amplified, as 2PC proves to be too fragile in practice.
It was only a few years ago when I changed my mind about 2PC. Coming from the world of tightly integrated client-server, I thought of 2PC as an architectural choice, the natural basis for implementations. But in a world of distributed applications that need to collaborate with each, 2PC became a design choice, a trick you would pull out on rare occassions when no other solution will do.
Where do you stand?
Image by a little azorean.
mult.ifario.us : Not Quite No Transactions