Microservices is probably one of the most popular buzz among my fellow developer friends, and I do like the concept of being flexible, agile and having simply having more choices. But as a person that worked in the software integration space for years, I started to see some resemblance of the old ESB days.
Looking at the problem from ten thousand feet up. A decade ago, we had to come up with a better way of organizing the spaghetti connection in between systems, stop duplicating effort on the same piece of business logic. That is when Service oriented architecture(SOA) became popular. By modularizing services, sharing them among others systems, and organize ways of communication, routing of data. And ESB is one implementation of that, maybe not necessary how it should be done.
I was very fortunate to participate in many of these kind of integration projects, and lead some myself. We worked with various middleware vendors, at the time the solutions was all about ESB. By removing the complex interconnecting logic between systems into ESB, negotiating data model among teams (with application/services leaders), setup WSDL contracts for webservices and adding BPEL processes if needed between calls. And I had seem a fair share of amount of these ESB myself, outside of ESB the everything seems very organized. But lift up the ESB “box” you will find many of them end up with even worst tangled spaghetti code (or diagrams depends on your tooling). And that giant bundle of chaos, then become the bottleneck in delivering changes in enterprise.
(On the side note. This is when I started on the lightweight ESB idea, and how I was introduced with Camel, Karaf, servicemix because it solves my problem of being to independently bundle my integration code and breaking that ESB box into smaller distribution..and so on..)
When the idea of independently deployable microservices came along. This giant monolithic monster with idea of smart pipe where it tries to do too much, like data model definition, process flow, interconnect protocols and data format transform ...etc and dumb endpoint where services just waits to be activated by events was soon cast aside by developers. The relation between each services are still messy and the monolithic nature make the cycle of development long and cumbersome. The microservice allows developer to be more agile, who needs that piece of “Integration”. So this where the resemblance of a problem where I once trying to solve :)
And let alone we still need to interact with other services(systems/applications) outside microservices. So learning from past here are the things we know what NOT to do..
- No more large monolithic bundles application to speed up the dev cycle.
- Stop doing complex business process inside system integration code
- Data model shouldn’t be defined in the integration layer, it only leads to extra negotiation between teams.
- State should not be keeped in the integration layer to allow maximum scalability
- Create fix complex contracts between services.
And still there are things we liked about the old "integration" way.
- Organized visualized interconnect view of systems.
- Patterns that are already defined for integrating applications such as aggregations, separation, normalization of data.
- Event-based approach. A more reactive way and less coupled ways to integration systems.
And that is why I came up with the layered architecture for microservice. The main goal that I wanted to achieve in the new integration architecture in the modern integration/application development is flexibility. Not only in the scalable way but also allowing developer to make any architectural change with ease.
So first thing first, in the new modern agile integration, the integration code itself should be sorted into different small services that make sense in the business world. And are decoupled and made them to be independently deployable microservices units. Then we can start apply true CI/CD to the integration code. This will avoid becoming a large monolithic ESB.
In order to bring some logical sense to my microservice spaghetti, and avoiding repeating the mistake of taking on too much in one single integration bundle. I have defined four layers for my microservice, so each will have it’s own responsibility making it easier to adopt changes.
Originally I want to divide this layer into two, but decide not to because the gateway pattern has become so popular now, people has the perception of gateway should achieve certain ability. (That is a whole other story I want to talk some other time). That is why I have two separate form of the gateway in my diagram, one represents as green other blue.
It’s all about the separation of concerns. This layer is all about generating putting together what is needed for external API consumption. This is where and when separate application domains tries to integrate with each other. And route to the correct versions of services. And clearly the two major concerns were,
- Accessing policy rules, versioning of endpoints. (APIs)
- Sets traffic throttle applying limits and policies
- Security of APIs
- Routing to correct versions
- Combine, transform return result to client.
- Citizen developer are the main creators here, they uses the capability provided by each microservice team to put together meaningful service to external clients.
- Collect, split, or normalized a canonical data format to external users.
- Translate data output depending on the clients
- Routing between application domains
- Composite layer Important middle tier that handles composition of multiple microservices. They do more complex routing from processing the content data and aggregates/split data and populate the split/aggregated result to other microservices by triggering events or simply passing it. This layer hides the complexity of microservices away from clients.
This layer is probably the layer that does most of the old time integration logic where it is responsible for
- Composing microservices
- By calling the API available from microservices, and transforming data as needed between them and routing data to the corresponding microservices based on it’s content.
- Triggers events within domain
- I believe strongly that event base does best at decoupling stickiness between each service. And allowing performance at it’s best because of its asynchronous nature. The event bus here doesn’t necessary has to be a message broker, but any forms of Bus.
- Enrich contents
- The content enrichment here should be specific to the format and avoid any business side enrichment when possible.
- Applying Integration patterns
- Old integration problem will not just go away in microservices world. By applying proven patterns, we can avoid making mistakes.
- The REST architecture specifically talks about a caching layer. It make sense for the composite layer to try apply caching mechanism because it’s non business related, but do make significant impact to the performance and fault tolerance ability of the system.
The composite services should also be included in the application domain, which I will talk about in the basic layer.
- Base layer Like the name which is most likely represents the basic components of the system. Handles data retrieval or business logic processing. Each should be independent and self-contained.
Borrowing from the idea of Bounded Context, in this case logically organized group of microservices into what is called application domain. Where each domain represents separate entities of business functions that shares the same data model, this eliminates the need for doing too much transformation in the code.
- Anti-corruption layer - This layer handles interface to legacy application or anything that work against microservice quick and flexible principle. This layer is built in protection wall to your system, by doing the transforming job and translate between two very distinct implementations of the system.
Till next time! :)