Introduction to Microservices

Sudipto Sarkar
Globant
Published in
4 min readMar 30, 2021

Before we discuss what is a microservice , first we need to understand what is monolithic architecture and what are the challenges we have with Monolithic architecture. Which will help us to understand the microservices better.

Monolithic Architecture

In our traditional software development approach we are basically following the monolithic architecture style. We design our application in different layers Presentation Layer, Business Logic Layer and Data Access layer . All these layers are dependent on each other, which make our application tightly coupled.

Benefit of Monolithic Architecture

● Simple to develop as compared to microservice applications .

● Simple to deploy the application as a single jar/war file is deployed.

● Easy to test and debug as compared to microservice application as all code bases are in one unit we can test it end-to-end.

Drawback of Monolithic Architecture:

● As Monolithic application contains all the code based in single application which is large and too complex to modify or add new changes

● As size of the application grows because of a single code base which slows down start-up time.

● For each new change every time deployment of the entire application is required.

● Scale of a individual module separately is not possible, because each service has different resource requirement.

● Bugs or Defects in particular modules may lead to bringing down the whole application.

● It is difficult to adopt the new technologies in Monolithic architecture since change of framework or language lead to rewriting the whole application.

Microservice:

Microservices is an Architecture style which has only one responsibility or single logic to solve a specific problem. It is a lightweight form of service-oriented architecture (SOA) where the services are used for specific work. Each service is built separately with its own database. Business requirement is decomposed into smaller modules with well defined interfaces. So that small team can maintain and deploy these modules individually for the whole lifecycle of the service. In DDD ( Domain Driven Design ) context, Microservices are often targeted to fulfill functionality of specific domain.

The advantage of building separate services is like maintainability is easy. Maintenance of large, complex applications is easy because each service is maintained separately as compared to monolithic applications.

Every microservice should have following characteristics

● A microservice is responsible for single capability.

● A microservice is individually deployable.

● Each service from microservice can have a separate database.

● A microservice is replaceable.

● A small team can maintain a handful of microservice.

In Monolithic application for scaling of the application we need to scale the whole application but in case of microservice we can be scaled independently. In Microservice you can scale just a particular service which requires more network bandwidth or processing power to support the demand, which saves cost as well as Hardware requirement.
Let’s have a look how microservice architecture works.

Microservice Architecture :

Instead of building one large monolithic application, split the application into smaller service which can be interconnected with each other. Each service can have their own database as well as dependencies.
As we Can see in the above diagram UI from any platform(mobile App, Web App, Single Page Application(SPA) )can communicate with API gateway and gateway will decide which service to call to serve the request.
Each service can have their own framework, language and database. Service Bus helps to make intercommunication between different services.

Benefit of Microservice:

● Decompose the application into smaller services which are much faster to develop and maintain.

● Since the entire application is more like a group of services that are isolated from each other, deployment could be done one microservice at a time, if required. Failure in any one of these would not bring the entire system down.

● Each service can be scaled independently, so no need to scale the whole application.

● As services are independent, developers are free to choose technologies based on the requirement for their module. Suppose, team one is going with Java and sprint boat for service. Team two is using Python and Node for their services. This is also known as polyglot microservices.

● Micro services are highly available and if one service is failed it will not cause to shut down the entire system.

Drawback of Microservice:

● Inter-process communication between the services are difficult as need to choose a message or RPC mechanism to write the code.

● Testing the microservice is complex as services are dependent on each other which need to manage properly for executing test cases.

● Deployment of micro services are more complex as each service needs to configure, deploy, scale, monitor separately.

Monolithic vs Microservice

Conclusion :

Microservice is suitable for build complex , multi-function application where we need to build scalable services as per business requirement. while we use microservice as architecture we first need to carefully evaluate our need.

--

--