Microservice architecture - Introduction

Microservice is a service-based application development methodology. In this methodology, big applications will be divided into smallest independent service units. Microservice is the process of implementing Service-oriented Architecture (SOA) by dividing the entire application as a collection of interconnected services, where each service will serve only one business need.

Thus, instead of having one big monolithic application which does everything for you, you split it up into handful of micro services where each micro service focuses on achieving one independent business logic function (say, authentication or login or user management etc).  Each microservice achieves very specific business goal in an application. These microservices can communicate well via well defined APIs (usually HTTP). Thus, microservices are in demand.



Basically, in a monolithic application, You tend to have one big application where you have User Interface that interacts with Business logic layer where all your business logic functions are written. Your business logic layer then interacts with Data access layer.  Thus, your business units are dependent on each other. Thus, monolithic applications are your traditional big size applications.  If you take the example of online CAB booking application. If we want to build using monolithic SOA architecture, you will have the software units like 

1. Get Payments and driver information and Mapping API

2. AuthenticateUsersAndDrivers API

If you want to build above CAB application using microservices architecture, then its APIs will be:

1. SubmitPaymentService

2. GetDriverInfoService

3. GetMappingDataService

4. AuthenticateUserService

5. AuthenticateDriverService

Thus, each microservice does an independent business logic function. They still share the one user interface. Microservices can either share a database or can interact with their own database. Each microservice can inturn trigger/initiate other microservices as well. 

Following are some rules that we need to keep in mind while developing a Micro-service-oriented application. 

Independent − Each micro-service should be independently deployable. 

Coupling − All micro-services should be loosely coupled with one another such that changes in one will not affect the other.

Business Goal − Each service unit of the entire application should be the smallest and capable of delivering one specific business goal.

Following are some points on the advantages of using microservice instead of using a monolithic application.

Advantages

Language independent − you can write one microservice in Java, the other microservice in .Net. It really does not matter which language, each microservice is written into. Thus, microservice supports different technologies to communicate with each other in one business unit, which helps the developers to use the correct technology at the correct place. 

Small teams & Faster iterations - In a monolithic application, you may need big number of teams because you build real big size applications. However, incase of microservices, you really need small team size of 3 to people. As mentioned earlier, each microservice is designed to deliver only one business task. While designing a microservice, the architect should be concerned about the focal point of the service, which is its deliverable.Thus, microservice development teams fit into iteration based process model

Autonomous − Each microservice should be an autonomous business unit of the entire application. Hence, the application becomes more loosely coupled, which helps to reduce the maintenance cost.

Resilience / Fault Isolation − Resilience is a property of isolating a software unit. Microservice follows high level of resilience in building methodology, hence whenever one unit fails it does not impact the entire business. Resilience is another property which implements highly scalable and less coupled system.

Ease of deployment − As the entire application is sub-divided into small piece of units, every component should be full stack in nature. All of them can be deployed in any environment very easily with less time complexity unlike other monolithic applications of the same kind.

Scalable − By implementing a heterogeneous system, one can obtain maximum security, speed and a scalable system. Scalability is a big plus incase of microservices architecture. Microservices are dynamically scalable in nature. Thus, You can take advantage of cloud computing. As you scale up, you can purchase on demand cloud based nodes. As you scale down, you can get rid off unused cloud nodes. Thus, you can save big money for your enterprise.

Disadvantages of micro-service architecture.



Complexity − As you see above, as we grow in usage of micro services, it is difficult to trace or figure out which micro service is calling the other microservice. Thus, the traceability of different microservices renders complexity to maintain it.

Distributed system − Due to technical heterogeneity, different technologies will be used to develop different parts of a microservice. A huge set of skilled professionals are required to support this big heterogeneous distributed software. Hence, distributed and heterogeneity stands as a number one disadvantage of using microservice. 

Overhead (Servers and Infra architecture) − We need to gain and maintain knowledge about various servers and infrastructure architectures to solve problems.

Cost − Microservice is costly, as you have to maintain different server space for different business tasks.