Skip to main content

Microservices with Mule

Microservices has been a buzz word for past few years. It talks about a technique of designing integrations and APIs as an independently deployable service. While there is no exact definition of this architectural style, there are certain common characteristics around organisations around business capabilities, automated deployments, intelligent endpoints and distributed control of data.

Before we start on microservice style, it would be useful to compare it with the monolithic style. A monolithic application is built as a single unit. Enterprise Applications are often built in three main parts: a client-side user interface (consisting of HTML pages and/or JavaScript running in a browser), a database (consisting of many tables usually a relational database management system) and a server-side application. The server-side application will handle HTTP requests, execute some domain specific logic, retrieve and update data from the database and populate the HTML views to be sent to the browser. This server-side application is a monolith - a single logical executable. Any changes to the system involves building and deploying a new version of the server-side application.

Such a monolithic server is a natural and has a simple approach for building such a system. All the logic for handling a request runs in a single process, allowing us to use the basic features of the language to divide up the application into classes, functions, and namespaces. With some care, we can run and test the application on a developer's laptop, and use a deployment pipeline to ensure that changes are properly tested and deployed into production. We can horizontally scale the monolith by running many instances behind a load-balancer.

Monolithic applications can be successful, but increasingly people are frustrated with them as more applications are being deployed to the cloud. Change cycles are tied together; even if a small change is made to the application, it requires the entire monolith to be rebuilt and deployed. Over time it is often hard to keep a good modular structure, making it harder to keep changes that ought to only affect one module within that module. Scaling requires entire application to be scaled rather than parts of it that may only require more resources.

These obstructions have led to the Microservices architectural style of building applications as suites of services. These services would be independently deployable and scalable. Each service also provides a stable module boundary, even allowing us to write different services in different programming languages. They can also be managed by different teams as well.

Microservices

There is no formal definition for Microservices architectural style, but we can frame our understanding based on the details that microservice approach to division is different, splitting up into services organised around business capability. Such services take a broad-stack implementation of software for that business area, including user-interface, persistent storage, and any external collaborations.

The common manifestation of SOA has led some microservice advocates to reject the SOA label entirely, although others consider microservices to be one form of SOA. We will discuss here how it fits our purpose in the integrations.

Here we can see a difference between the monolithic architecture and a microservices architecture. There may be a few variations based on the distribution of the back end services of the databases. In some cases the legacy backend applications may not be shifted or changed as influence of cost plays an important role.

Microservices with Mule

Here we see that the services are broken down based on the business modularity and those can be developed and deployed independently of each other unless the business required all at the same time.

We can achieve a clear micro service architecture for any green field project. There can be various solutions based on the existing enterprise architecture, availability of requirements and customer’s view resulting into different type of implementations. But we can ensure that the services implemented can be made available in a modular approach so that they are developed and delivered independently.

The micro service architecture illustrated in the above diagram has a third service with two instances. We can scale individual services instead of full set of applications based on the requirement and the volume expected for individual service.

Considering the above example in the image, the monolithic database may be an existing system  for which the customer may not be willing to transform as their current business might have an impact and would also cost a lot. In these cases, we can create an integration architecture that would cater to the need of mediating the existing services and provide APIs that can be independently deployed and exposed for the other external systems that is expected to be integrated into the system.

The approach to micro services is not about hitting it directly but rather about designing the whole set of services, then group them functionally and split them further into micro services accordingly.

How MuleSoft ESB comes into play

If we follow micro services architecture principles and choose to implement granular services, we can easily deploy these services on the CloudHub independently and can scale up or down as and when necessary without impacting any other services within the EAI landscape. Each service or API is created as a separate application containing the mediation flow required for the underlying requirement. Every individual application can be managed independently. The same is possible if we plan to go with the Mule ESB EE deployment strategy as well. The scaling factor is out of the box supported on CloudHub through the admin console whereas for EE deployment it would be dependent on the underlying infrastructure design.

Supplementary Benefits

Parallel development can progress as the functionalities are not overlapping and these are designed to operate independently. Placing these components and APIs as micro services also provides an opportunity to plan granular releases. This also implies that the releases can follow agile process and methodologies.

Some benefits include exposing of granular services from the legacy applications or complex solutions that can be consumed by new ecommerce solutions and / or mobile applications.

It is not necessary to have a full detailed requirements for all the planned services. We can create, enhance and expose the services to the consumers with an agile/iterative delivery model.

If you would like to find out more about how APIs could help you make the most out of your current infrastructure while enabling you to open your digital horizons, do give us a call at +44 (0)203 475 7980 or email us at Salesforce@coforge.com

Other useful links:

Integration with Dropbox using Mule ESB

Mule Transactions for Reliable Message processing in CloudHub

Integration of Mule ESB with Microsoft Azure

Let’s engage