Tags

, , ,

Presently, there is a lot of hype in the industry, especially large enterprises, to adopt Microservices architecture due to the benefits it offers when compared to monolithic architecture. However, it is important to understand that adopting Microservices is not a free lunch as it not only impacts just the technology but also people, processes and the team organization. Without considering the organizational readiness and commitment towards the microservices journey, it  could prove detrimental.

Let’s understand what are microservices and why we need them at the first place.

What Are Microservices?

Microservices is an architectural style where an application is composed of many small services running within its own bounded context and communicating via open protocols primarily HTTP. It it not a new technology, but rather promotes the use of multiple existing technology stacks within a single application that best supports the use case.

This architectural style can be contrasted to a monolithic application which consists of single executable (WAR, EAR etc.) containing multiple components/modules written in a single programming language. In case of Microservices, each service could have it own technology stack (programming language, database etc.) and can be deployed independently.

Following diagram shows a sample monolith banking application having multiple user interfaces and supporting functionality like origination, customer details, account details, account activity, funds transfer etc. The functionality is provided by a monolithic application that persists data to a single relational database.

Monolith

With advancements in the persistence technology, we have lot many options these days than just the relational databases. Depending upon the use case, it might be more efficient to use MongoDB for storing JSON documents or Redis for storing key/value pair in the memory. There could be applications that need to store objects like images, files etc. for which object storage might be a better solution than storing the blobs in the database. Some use cases need relational database with ACID properties for transaction management for which SQL database is the best fit.

Drawbacks of monolithic applications

Following are some of the drawbacks  of a monolithic application

  • Leverage a single technology stack and it’s difficult to integrate new technology innovations
  • Even a small change in one of the application component requires repackaging and deployment of the monolith
  • Challenging for a new developer to understand the application scope and functionality
  • Scaling out the application requires the monolith to be replicated

Microservices Architecture

The diagram below shows how the banking application described above could leverage microservices architecture to have independent microservices that supports a business capability. As we can see, each microservice has its own database and any interaction with the underlying database is supported by the microservice that provides an interface to the database. Also, the calls from the client devices to the service tier are routed though API gateway which offers lot many benefits in addition to reducing the complexity at the client side.

Microservices

Each of this Microservice could be independently enhanced and deployed without impacting the other services during runtime. Also, each service can have its own technology stack and use different programming language types i.e. imperative vs functional. This provides the agility to implement new changes quickly and get them to production faster.

Challenges with Microservices

The approach of breaking the monolith into multiple self-contained services has its own challenges as discussed below.

  • Due to large number of services, the probability of failure increases. It’s important to design the application with fallback mechanism knowing that services would fail
  • Microservices architecture does not support distributed transactions and therefore the design should rely on eventual consistency
  • It’s an operational challenge to manage large number of inter-dependencies between the services and monitor the application

As we have seen, microservices architecture has its own advantages and disadvantages when compared to monolithic application and it requires a careful consideration when deciding application architecture. Microservices require additional infrastructure and due diligence to overcome some of the challenges described above, however if done right can help the organization to be more agile and innovative.

You can read more about the microservices architecture by navigating to the following links

Cloud Native Applications

Spring Cloud Configuration

Service Discovery – Spring Cloud Eureka

Summary on Cloud Native Applications and Microservices can be viewed by navigating to the link provided below.

Presentation – Cloud Native Applications and Microservices