Friday, March 20, 2015

The Microservices Pattern

For those of us that have been practicing SOA for over a decade, it's surprising that there's so much interest in microservices. In fairness microservices don't look like the vendor play that was early SOA in the early noughties. But experienced SOA practitioners everywhere will be wondering if microservices is actually a good thing. You see microservices is basically an SOA pattern that inherits all the well-known SOA principles and adds characteristics that address the use of SOA for distributed, finer grained software services. And like all patterns, microservices are not applicable to all situations, and it's very important to understand the cost/benefit equation. Those folks that are heralding microservices as the "new SOA" or "the right way to do SOA" are flat wrong. Microservices is a specialization of SOA that has applicability to a relatively narrow problem space.

Componentized Services and Decentralized Data Management.

Capability based services that have reduced dependencies and single point responsibility for data has been a widely used SOA pattern. What's different with microservices is the decentralization of data management and encapsulation of the data in the service component. This is a useful pattern for services that can really own the data AND have high probability of churn in the service information model. The reduced horizon of change will be highly effective in responding to continuous business evolution.  But there's a serious cost to this, and Fowler et al surround the distributed data management advice with caveats.  They say, "Decentralizing responsibility for data across microservices has implications for managing updates. The common approach to dealing with updates has been to use transactions to guarantee consistency when updating multiple resources. . . . Using transactions like this helps with consistency, but imposes significant temporal coupling, which is problematic across multiple services. Distributed transactions are notoriously difficult to implement and . . . as a consequence microservice architectures emphasize transactionless coordination between services, with explicit recognition that consistency may only be eventual consistency and problems are dealt with by compensating operations."

Anyone who has dipped their toe in to this complex and murky pool knows that you do distributed data only when there is a real business requirement that demands this level of sophistication. In the typical enterprise environment there's a requirement for a range of SOA relevant data patterns. Distributed data is just one of many.  

Decentralized Governance

The vision of microservices is very reasonably to facilitate heterogeneous technology platforms. But the Fowler guidance goes much further. "Perhaps the apogee of decentralised governance is the build it / run it ethos popularised by Amazon. Teams are responsible for all aspects of the software they build including operating the software 24/7. Devolution of this level of responsibility is definitely not the norm but we do see more and more companies pushing responsibility to the development teams."
But you don't have to be a Luddite to think that there are elements of governance that need to be centralized; and I'll bet are standardized in Amazon. For example, at a basic level security, logging, reference data and return codes, contract and API meta data and data management (see above), life cycle management etc. But in our practice we also see massive advantages in standardization of much of the (platform independent) architecture runway, SOA patterns etc. The advantages are not just about productivity and quality, which are considerable. They also deliver consistency of approach that has many less tangible benefits in terms of skills and resources, knowledge sharing and integrity of the delivered solutions, while still supporting heterogeneous target platforms. Perhaps this demonstrates the divide between the architect and developer viewpoints. And I have seen far too many enterprises getting into deep water because they have allowed the pendulum to swing too far towards developer independence.  

The concept of microservices is clearly creating much interest and confusion. I commented on the Newman book in an earlier blog that the author didn't seem to understand the difference between a pattern and a process. And perhaps this is the issue with microservices. The concept is essentially about decentralization and distribution, creating freedom of action for developer led teams that deliver something useful for (probably) a narrowly defined set of users. It all looks good in terms of ticks in the "project delivered" box. But it also looks remarkably tactical. And as I commented in my recent blog, lack of consistency leads to inability to govern and increased time to market. And my guess is that microservices, in the way they have been defined, will lead down a very similar path.

Nonetheless, there are some useful aspects to microservices. DevOps specialists are seeing real benefits from smaller units of deployment. Promotion of some of the basic elements such as componentization, automation and evolutionary design are a good thing. But adopting the microservices characteristics as a unified pattern as described is really only applicable to a narrow problem space. And as soon as you adopt the characteristics piecemeal, you have to reassess the cost/benefit. I expect that the widespread interest in microservices will lead to it morphing into a simpler, less complex pattern that does address a wider problem space. But surprise, surprise, we solved that a long time ago, and all we are doing is renaming highly independent Capability based services as microservices!

References: Microservices, Lewis, Fowler, March 2014

No comments:

Post a Comment