Microservices Architecture

During last few years Microservice based architecture has got spectacular attention in the field of Information Technology. This spectacular attention is due to its unique way of designing application into smaller interconnected components.

What is Microservices?

             Microservice is an Architectural way to design an application by splitting the application into several small modules which are packaged and deployed individually. It is the process of implementing Service-oriented Architecture (SOA) by dividing the entire application into a collection of interconnected services, where each service will serve only one business need. Previously we practiced developing and deploying an application in Monolithic approach.

What is Monolithic approach?

Monolithic approach is an architectural way of designing applications before to micro service architecture. In Monolithic approach we generally develop each service of the application individually but at the end of developing, we will package all services as single war file and will deploy in Server. Let’s continue our discussion in brief by exploring with a small example, suppose in my application I have 7 services which are dependent on each other. If I changed business in one service then I am forced to repackage and redeploy entire application to make all services work which is a big disadvantage in Monolithic approach.

There are many popular sites that developed their application with Monolithic approach

  • Flip-Kart
  • Amazon
  • Uber
  • EBAY

Explore more about Monolithic approach by considering some services of Amazon

  • Account Service
  • Order Service
  • Payment Service
  • Shipping Service
  • Notification Service

                         As per our example, Amazon is providing 5 services to its customer so that anyone can login and browse or order for products. The ordered products will be show as a list in notification bar and payable amount will be shown along will the products and one can pay using payment option. So here all these are different services provided by Amazon to its customers. As Amazon previously using Monolithic architecture and providing payment option with any banking services. But now Amazon management wants to include tez as a payment option along with banking services to increase their sales by making payment easy for their customers. To include tez they need to make changes to payment services. Immediate changes to the payment service will not happen because in Monolithic architecture every service will be packaged into one single war file. So they need to wait for next release to include tez which takes time.

Cons :

  • As we deployed every service as single entry point (WAR), performance will be slow as WAR contains more data.

  • Bug tracking and fixing will becomes too much difficult to handle.

  • Adapting to new technologies or languages will be difficult. As adopting one new technology in a particular service will impact on other services.

  • Code Readability will not be there.

These Cons are overcome in Microservice architecture as follows :
In micro service-based architecture, we generally develop, package and deploy individual modules of the entire application independently. Even though each service in an application is interlinked with each other, all services are separated with an independent war. So that failure of one service will not impact any other service of the application. All above mentioned 5(Account Service, Order Service, Payment Service, Shipping Service, Notification Service) services have their own development, package, and deployment. There is one API gateway who manages all microservices and act as a front entry point.

What is API Gateway?

The API gateway is a service that provides each client with unified interface for services. These API Gateway can be any Cloud environment or Eureka or Zuul proxy server. So from User Interface we are not going to communicate directly to our micro services. First of all when we send the request it will comes to API-Gateway, based on incoming URL pattern it will find the mapping controller from Service Registry and then it will delegate the request to corresponding controller and execute the business logic.

Development procedure and deployment procedure of Microservices

As we looking into 5 microservices, am not going to deploy all as Single war then think how can I achieve features from one service means how to Communicate from one service to another, That’s why a lot of the third party give hands to support Microservices architecture, Netflix is one of them who provide us with great features to register N number of microservices, so he provided one embedded server that is Eureka where we can register our Microservices to communicate with each other. So here API-Gateway is nothing it can be any Cloud environment or Eureka or Zuul proxy Server. So from UI we are not communicating directly to our microservices, First Request will come to API-Gateway then based on incoming URL it will find mapping Controller from Service Registry then it will delegate Request to the corresponding Controller and process the business So think how the process and performance is faster in microservices as compared to Monolithic application it seems we can achieve more scalability.

  • As i deployed each service individually in different container and assume registry in Eureka Service Registry performance won’t be slow. As each is one microservice, So quick development and delivery becomes faster and easy to track Bug and fixing.
  • Repeated deployment will not suffer a lot. This is because, let’s say you want to fix a bug in one of the component in the application. Now as this module is independent just do the changes on that specific module and deploy only that module, no need to bother about other services as they are already registered in Service registry.
  • Adoptingto new technologies or languages will be very easy. As you can implement one language for one module of the application easily.
  • As each service are separate war or jar with less data specific to particular module so server start up will not take much time, we can up the server in multiple port and auto restart in every logic change so, for that we need to use either dev tools or spring loader.
  • Exception propagation is proper if any service failing then it won’t Impact on entire application.
  • Code Readable is very clear, suppose one new resource joined in your project and got a task to work on Shipping microservice so they can easily open that service and can check the flow as it is individual service.
  • So this is All about Why Microservices, what are the advantages, why people are hugely running for Microservices, why not monolithic Architecture.

Author : Madhu Vamsi Krishna Pendurthi – Web Developer
Source : tutorialspoint,SrimanJavaGroup

Share This Information