What is Micro Services.
By the name it is clear that we are talking about mini services which are able to perform their task independently. Micro Services follows micro service architecture instead of monolithic architecture. Whenever we say that application build on microservices architecture that means that this application is not dependent on one services but rather it is dependent on several many services.
Whenever a request is made through application UI by the user then that application is calling different other services for fulfillment of the
single request. Lets us take small fictitious example of E-comm system that take the order from the customer, verifies its inventory and ships the order to the customer.
single request. Lets us take small fictitious example of E-comm system that take the order from the customer, verifies its inventory and ships the order to the customer.
Fictitious E-Commerce System.
This system will perform several task such as.
- Placing the order by customer.
- Checking the inventory.
- Shipping the order to the customer.
- And and user interface to access this application.
Now, in normal monolithic architecture above all steps will be performed under single service but in Microservice above all operation will be decomposed into several small services which will perform independently. This decomposition can be done on basis of domain of business or services that business is performing or it may be other different use case. we will talk about decomposition in detail in our later posts. For our application we will be doing the decomposition on the basis of services its providing. Lets see the below picture to get clear picture.
Credit : microservices.io
Above picture clearly depict that
- Client can make access our application through Mobile or Browser.
- Request coming from mobile will go to API Gateway and request from mobile will go to Webapp.
- Request coming from mobile and web app will go required services like Account Service, Inventory Service and Shipping Service.
- And each service will hit their independent databases.
From the above discussion we came to conclusion that MicroService Architecture can be defined as the architecture in which entire web application is decomposed to several loosely coupled and collaborating services with related functionality and independent databases.
Here all component(Account Service, Inventory Service,Shipping Service and there respective databases) will interact together to process user request. All services may interact with each other using api calls.
Benefits of MicroService Architecture
- Ease in Testing: As services cover small independent function so it can be tested easily in less time.
- Small Team : Each services can maintained and developed by PIZZA SIZE TEAM means team with size 4-6 members.
- Ease in Training: New team member can be easily trained as he has to cover only small portion of the application.
- Cross Functional Team: Team can learn other services easily and that will help in creating cross functional team.
- Easy and Continuous Deployment: As each services are independent therefore each service can be deployed easily without bringing entire application down. And that will help in continuous deployment.
- More Productivity: As application is small then IDE used will be fast and will make developer more productive.
- Easy Technology Upgrade: Services can be easily upgraded to new technology stack as only small portion of the entire application is to be upgraded. I.e only one service at a time is needed to be upgraded with newer technology without affecting the other services.
- Improved fault Tolerance: If any service failed then it will not bring down entire application. Only that specific services will be impacted.
- Easy Maintainability: Maintaining entire application in one time is more harder than maintaining in small chunks.
Drawbacks of Microservices Architecture
Microservice architecture is not full prove but also comes with several drawbacks.
- Extra Unit Testing Efforts: As services need to contact with other services to perform operation therefore developers have to develop a method to talk with other services.
- Tough Implementation: Use cases of one service may include other services which will create development difficult.
- Dependency Between Team: As services are dependent on other services therefore coordination between other teams needed to be made while developing the service.
- Increased Memory consumption: As one monolithic application is decomposed into N services therefore N services instances are needed to keep the entire application up and running.