Cross service communication in SOA
Creating a distributed software system based on Service Oriented Architecture (with Microservices implementation technique as a possible approach, more on this here) very quickly presents a question of communication between the services in the system. Communication choice may greatly affect non-functional requirements such as stability, availability, reliability, maintainability and other “-abilities” of the system.
To increase your chances of success it is important to understand that SOA based software systems require communication that promotes autonomy, spatial and temporal decoupling, reliability.
Let’s look at a point-to-point (direct) communication pattern, which often is promoted by various vendors and Microservices evangelists. The premise is very simple – create microservices that “do something small” and let them talk to each other via some sort of an RPC protocol (underlying technology doesn’t really matter). Let’s look at how that behaves and quickly identify potential pitfalls with such approach (see video below):
As you can see, there are few major issues with such communication style:
- Spatial coupling – requires services to be aware of each other, and able to reach out to each other
- Temporal coupling – requires services to be present at the same time in order to ensure successful operation
- Failure of a single component may take down most if not all of the system, causing cascading failures and unavailability of functionality to customers
- Development and deployment coupling – high probability of a change in one service causing cascading changes in other services, complex orchestration during development, testing and deployment into production
- High probability of introducing distributed transactions for situations where services boundaries are not properly defined
The disadvantages are quite obvious yet there are a lot of projects that default to this style of communication with engineers blaming the failures (caused in part by this choice) on selected implementation technique.
Now, if we consider services boundaries and the factors that come from that, we quickly realize that our needs for cross-service communication are greatly reduced – our business transactions are encapsulated within a single module that works or fails on its own, with no dependency on anything else. This means – a service never needs to reach out anywhere outside of its boundaries to fulfill its purpose.
Once we consider such service autonomy, the communication needs change dramatically. This is where Event Driven Architecture comes into picture and the synergy of SOA and EDA produce a powerful combination – ability to notify the system about a change in a service’s state via events, which promotes much lower coupling between components.
Let’s look at a pretty standard sequence of steps happening in such environment:
- A business transaction gets initiated via a request from a user or another component / system
- A service fulfills a business transaction, which results in the change of its state.
- The state change is announced – anyone interested in this specific change gets a notification with details of the change
To enable EDA we need to have an infrastructure that provides a mechanism to publish and consume notifications. One of the most obvious choices in this situation is a message broker or a service bus.
The benefits of such approach:
- Service autonomy is much stronger promoted due to constrains imposed by communication style
- Spatial coupling is no longer present – services don’t need to know about each others location
- Temporal coupling is eliminated – there is no need for one service to be running at the same time as others
- Failure of a single component leads to a degraded system performance, not a cascading failure of multiple components
- Development time coupling is greatly reduced, deployment coupling is virtually eliminated
- Distributed transactions are still possible as they are a result of an incorrect services boundaries, however this communication style makes them more obvious and visible, thus allowing for design corrections
What are the most obvious drawbacks of introducing messaging into the mix? Well, there are at least the following:
- There is another technological artifact to deploy, monitor, maintain, which really means extra cost.
- If your organization doesn’t have ESB (message broker) this would be a new piece of technology
- Monitoring tools and processes to ensure issue resolution
- Communication pattern requires different ways to respond to failures – dead letter queues, component recovery, etc.
- This is a compromise to enable overall greater system availability and reliability
- Different programming mindset and model
- Really is needed regardless to ensure successful design and implementation of an SOA based distributed software system
Microservices without fundamentals
Couple weeks ago an article was brought to my attention. An article with a catchy title – “The Death of Microservices Madness in 2018”. Since I am greatly interested in software architecture for distributed software systems such statements are definitely too bold to be ignored.
One of the biggest misconceptions about Microservices I’ve observed is that people accept the idea as something holistic, self-contained and self-sufficient. In reality, Microservices is just an implementation approach for distributed systems architected and designed according to much wider concepts – Service Oriented Architecture, Event Driven Architecture, Domain Driven Design. Looking at microservices in a disconnect from these architectural styles is a mistake that will become costly and may lead to an ultimate failure. More on this here.
Read More»Microservices as a self sufficient concept
Over the past few years microservices became a very hot topic in development communities. More and more people talk about the approach and attempt to build large software systems according to various patterns published by enthusiasts. The buzz words (and buzz concepts) are a big driving force in software development, which in a lot of cases results in failures, as people simply don’t research and learn the subject deep enough to be able to make informative decisions. I think one of the concepts suffering from such high level approach is distributed systems development, which some are trying by going with microservices model.
I am greatly interested in software architecture for distributed enterprise-level systems and I believe that microservices concept has not only been greatly misunderstood by many, but also is flawed in the way it is presented – as a self sufficient “architecture”. However, microservices is merely an implementation approach and without proper fundamentals will not magically lead you to success. What are those fundamentals you may ask? Well, read on – this is not going to be very long, even though each of the fundamentals is a very large subject.
Read More»